Unable to install Sylius with Composer - symfony

With composer, i tried to install Sylius via sylius/sylius and sylius/sylius-standard.
Installations have both ended like this :
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
It happens just after the parameters.ini initialization.
And after, the command line doesn't work (example : "app/console list" return nothing) although I'm in the project root directory.
Any idea, please ? Thanks.

I've gotten this error ( I'm not sure if it's the same place where your getting it ) and developed a solution that seems to work. Instead of running app/console cache:clear ( which I think gets run at the end of the composer install ), I run a bash script that opens the permissions before and after.
sudo sh clearCache
Contents of clearCache:
#!/bin/bash
chmod -R 777 app/cache/ app/logs/
su www-data -c "app/console cache:clear -e dev"
chmod -R 777 app/cache/ app/logs/
su www-data -c "app/console cache:clear -e prod"
chmod -R 777 app/cache/ app/logs/
I think I got this message during a composer install and was still able to continue via cd Sylius and app/console sylius:install. Just run this before and after installing and updates.

Related

Twig_Error_Loader - directory does not exist

I have this error when deleteing cache.
sudo php app/console cache:clear --env=prod --no-debug
[Twig_Error_Loader]
The "/Users/whitebear/CodingWorks/httproot/myapp/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/views" directory does not exist ("/Use
rs/whitebear/CodingWorks/httproot/myapp/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/views").
I deleted all vendor/* and reinstalled by composer, but this error continues.
sudo php app/console cache:clear
This command shows no error.
Remove cache manually - rm -rf var/cache/*
Clean spooled emails rm -rf SPOOL_DIRECTORY/*, by default rm -rf var/spool/*
Both from project root directory.

capifony deployment task order : site unavailable during grunt

I am using capifony to deploy my symfony 2 application.
I run two late tasks. During the time grunt is run, my website is unavailable. I've tried to play around with tasks order without success.
How should I configure the following task or what else should I do to make sure my website does not become unavailable durint the grunt process (ideally, the simlink to current would be changed after the grunt command has finished) ?
after 'deploy:restart', 'deploy:dump_dev_assets'
after 'deploy:dump_dev_assets', 'deploy:grant_permissions'
namespace :deploy do
desc "Dump dev assets"
task :dump_dev_assets do
run("cd #{deploy_to}/current && npm install")
run("cd #{deploy_to}/current && bower install --allow-root")
run("cd #{deploy_to}/current && grunt")
end
end
namespace :deploy do
desc "Grantpermissions"
task :grant_permissions do
run "sudo chmod -R 777 #{latest_release}/app/cache"
run "sudo chmod -R 777 #{latest_release}/app/logs"
run "sudo chmod -R 777 #{latest_release}/web/uploads"
run "sudo chmod -R 777 #{latest_release}/web/media"
end
end

getenv('SYMFONY_ENV') is empty in app/console from composer install, but OK elsewhere

To deploy my Symfony app on production I run the following command in a bash script:
php composer.phar install --no-dev --optimize-autoloader
And I got the following error :
Script
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-install-cmd event terminated with an exception
An error occurred when executing the "'cache:clear --no-warmup'" command.
This is because getenv('SYMFONY_ENV') in the app/console returns an empty value, while executing the commands from composer.json post-install-cmd. Therefore the $env value is not set to prod but to dev (default one).
However, the SYMFONY_ENV value is ok.
In the terminal, if I run:
printenv SYMFONY_ENV
It prints prod
If I run:
php -r "print_r(getenv('SYMFONY_ENV'));"
It prints prod
What I am missing or doing wrong ?
I just realized that I was running
sudo php composer.phar install --no-dev --optimize-autoloader
instead of
php composer.phar install --no-dev --optimize-autoloader
In my case (ubuntu 14.04), I had defined SYMFONY_ENV in /etc/environment and I thought it was accessible for all users, but it's not the case for sudo. I solved my problem running my command without sudo (because it had no reasons to be).
Another solution could be to run sudo -E php ... to preserve the user environment as suggested here : https://askubuntu.com/questions/161924/how-do-i-set-persistent-environment-variables-for-root

error about dependencies again and again

I took my project to another local computer and Im getting this error after requesting app_dev.php:
You must set up the project dependencies by running the following
commands: curl -s http://getcomposer.org/installer | php php
composer.phar install.
So I run those commands but the error is the same again...
You sure you use 2.0 version? Because composer is used in symfony 2.1
Can you show logs which occur when executing php composer.phar install?
Else try to:
Remove extra php word in curl -s http://getcomposer.org/installer | php php composer.phar install
Delete cache and make cache dir writable: sudo rm -rf app/cache/* && chmod a+rwx -R app/cache/*

I can't reinstall symfony2

I am using symfony2 standard version, on linux mint 12.
I created a symfony2 project 2 days and everything went well, i installed a wrong bundle and messed up the project so i decided to delete the Symfony folder, and reinstall symfony.
And now, if i do php app/check.php i get the timezone error, although my timezone is set correctly, and the configuration page looks like this
i tried
rm -rf app/cache/*
rm -rf app/logs/*
and i tried
chmod -R 777 app/cache app/logs
could not fix it
Edit
php bin/vendors install --reinstall fixed the issue (Hakan Deryal thank you sir). However, I found out that if you rename the Symfony folder to symfony or any other name, you'll get the error, or everything goes normal but when you press Configure your Symfony Application online you'll get this error
Server error
The website encountered an error while retrieving http://localhost/mysite/web/app_dev.php/_configurator/. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
So my next question is how to change of the symfony2 project , say you have 2 symfony2 project on localhost, they can't have the same name
Hi some time just clearing cache is not enough.
Event I came across the same type of problem, after clearing the cache, try to rebuild it.
commands are:
$ sudo php app/console cache:clear
$ sudo php app/console cache:warmup
$ sudo chmod 777 -R app/cache app/logs
The best way to set permission is to use ACLs:
sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
You could also try a chown www-data app/logs
Symfony reinstall at this point is not very relevant

Resources