I confirm that this is still an issue. Replacing the single quotes by double quotes works and fixes this issue.
We had this issue on our development environment as well as on our production environments.
I have replaced this in the CreatDocxFromTemplate file, and hoping this won't break in a future update.
Ps: using PHP 5.6.x on Ubuntu/CentOS
All the tests done about this issue passed without any change, using all OS described in the previous posts, so maybe it's a special PHP config.
Please run this sample using the PHP CLI mode withouth changing anything in the library:
If the error persists, we'd like to test it directly. Please send to contact[at]phpdocx.com an email, we'd need access through SSH to run the library through CLI mode.
We have tested it again using fresh installations of Ubuntu and CenOS and it works perfectly. We'd need to check it directly on your server, please write to contact[at]phpdocx.com
The most common mistake when working with parseLineBreaks is that you need to set line breaks as '\n' not "\n".
We also ran into this issue.
To reproduce it, try saving the contents of a textarea form field containing multiple lines of text to the database. If you then retrieve the field, and feed it into the replaceVariableByText() function with the parseLineBreaks option 'true', line breaks are not detected by phpdocx.
What "str_replace(array('\n\r', '\r\n', '\n', '\r'), '__LINEBREAK__', $value);" in the phpdocx source code does is look for the character '\', followed by 'r', followed by character '\', followed by 'n', or in hex notation: 5C 72 5C 6E, instead of 0D 0A.
It should work in the same fashion as the nl2br() php function.
The current version of phpdocx needs a literal '\n' to use the line breaks option, not a carriage return.
We have added a new task to add carriage return support in this option. At the moment the only solution is to use '\n' (or any '\n\r', '\r\n', '\n', '\r') to use the line breaks option. If you're using a text area please replace the carriage return by a literal '\n' before adding it.
We have uploaded a patch to add carriage returns support in both classic and namespace packages.
Until the release of a next version of phpdocx, all users with an active License Update Service may download them on the private area.