While working with a client recently, I found that deploying to WP Engine with Git had stopped working.
The following appeared on the command line when I ran
git push production
remote: - warning: syntax Error Found in wp-content/vendor/composer/autoload_static.php ... remote: - failed: we detected a PHP syntax failure.
autoload_static.php is only executed if the website is running PHP
5.6 or above because it uses things that break in older versions of PHP. WP Engine checks all the PHP files when they are deployed using git push for code that could break the site in version PHP
5.3. Since we are uploading code that would break the site (if it ever ran, which it won’t but WP Engine can’t tell that), WP Engine stops the upload.
The specific code in question is generated by Composer version
1.1.0 or above where optimizations were made for PHP
5.6 and above in
autoload_static.php. These optimizations include using concatenation when declaring default class properties in PHP, which was not available until
5.6. See http://stackoverflow.com/questions/5847905/cannot-use-concatenation-when-declaring-default-class-properties-in-php
So instead of
git push production master
you would run
git push -o nolint production master
Minimum Required Git Client Version
The support for -push-option was added to the Git client in version 2.10.0. If you are running an earlier version of Git, this fix will not work (see alternative solution).
You can determine what version of the Git client you are using by running
from the command line.
If using -push-option=nolint flag is not an option (e.g. you’re stuck using an earlier version of Git), you can also solve this issue by not deploying the offending file with Git push. This is done by deleting the file
$ git remove wp-content/vendor/composer/autoload_static.php
and adding it to your
Why am I Deploying the Vendor Directory with Git?
Generally, the Composer
vendor directory should not be included in the Git repo but since I can not run Composer on the WP Engine server, it is included on this project. Another option would be manually SFTPing the
vendor directory while excluding it entirely from the Git repo, which may be a better solution in this case but does create an odd requirement for deployment.