I am currently on Symfony2 2.3.7. When I run the composer update command. In the post-update-cmd a script is run to update symfony2. But it fails:
Script Sen
I had the very same problem. Even calling
composer create-project symfony/framework-standard-edition path/ "2.3.*"
in an empty directory failed.
After all I rebooted and everything is fine again.
One important Symfony requirement is that the app/cache
and app/logs
directories must be writable both by the web server and the command line user.
On Linux and macOS systems, if your web server user is different from your command line user, you need to configure permissions properly to avoid issues. There are several ways to achieve that:
In a terminal execute following commands :
rm -rf bin
rm -rf vendor
composer install
# or if your didn't install composer
php composer.phar install
It should work now! For more informations see Symfony installation.
If you still have this error : «An error occurred when generating the bootstrap file
»
It means that you have file permission issue.
See below procedure for solve the problem ↓
In a terminal execute following commands :
rm -rf app/cache/*
rm -rf app/logs/*
On macOS systems, the chmod
command supports the +a
flag to define an ACL. Use the following script to determine your web server user and grant the needed permissions:
HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "$(whoami) allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
On most Linux and BSD distributions don't support chmod +a
, but do support another utility called setfacl
. You may need to install setfacl
and enable ACL support on your disk partition before using it. Then, use the following script to determine your web server user and grant the needed permissions:
HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
# if this doesn't work, try adding `-n` option
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logs
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX app/cache app/logs
Change the umask so that the cache and log directories are group-writable or world-writable (depending if the web server user and the command line user are in the same group or not). To achieve this, put the following line at the beginning of the app/console
, web/app.php
and web/app_dev.php
files:
umask(0002); // This will let the permissions be 0775
// or
umask(0000); // This will let the permissions be 0777
Note : Changing the umask is not thread-safe, so the ACL methods are recommended when they are available.
For more information see official documentation : Symfony file permissions
Try to clean the cache with
php app/console cache:clear
and then try again
composer update
I ran into the same problem trying to use Symfony 3 on a Bluehost, shared hosting, server. I first had to find and use the php 5.4 client in order to get composer to run, then I got the same error you did. Check the docs here.
PHP needs to be a minimum version of PHP 5.5.9
So you are using a php client that composer supports, and Symfony does not.
Bluehost provides the php client v5.6.24 accessible at /usr/php/56/bin/php
.
So, using that php executable:
/usr/php/56/bin/php ~/my/path/to/composer.phar install
I successfully ran "composer install
" and all of the post-install-cmd's completed with no errors.
This is also the way to call bin/console
or in your case app/console
commands.
i.e.
## Symfony 2
/usr/php/56/bin/php app/console cache:clear -e prod
## Symfony 3
/usr/php/56/bin/php bin/console cache:clear -e prod
In my case I had no permissions errors. It had to do with a require() for disabled PHP functions in the pnctl-event-loop-emitter library. The composer autoloader was failing hard and crashed the script. The solution was to enable pcntl_ functions in php.ini.
The offending file was vendor/composer/../gos/pnctl-event-loop-emitter/src/functions.php
; This directive allows you to disable certain functions for security reasons.^M
; It receives a comma-delimited list of function names. This directive is^M
; *NOT* affected by whether Safe Mode is turned On or Off.^M
; http://php.net/disable-functions^M
; disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
disable_functions =
I saw this error too. In my case the error stopped when I disabled the APC extension in php.ini.