symfony2.7 FOS USER error on prod - symfony

I just try to connect on my website using the app.php with
new AppKernel('prod', false);
and i got an error 500 when login and stay blocked on /login_check.
But if i change it to:
new AppKernel('prod', true);
its work with no problem!!
So i check the prod.log of symfony and here what i found:
[2015-06-24 13:47:11] php.CRITICAL: Fatal Compile Error: require(): Failed opening required '/var/www/html/crm/app/cache/prod/doctrine/orm/Proxies/__CG__dmMembreBundleEntityMembreAuth.php' (include_path='.:/usr/share/pear:/usr/share/php') {"type":64,"file":"/var/www/html/crm/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php","line":209,"level":6143,"stack":[{"function":"getProxyDefinition","type":"->","class":"Doctrine\\Common\\Proxy\\AbstractProxyFactory","file":"/var/www/html/crm/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php","line":119,"args":[]},{"function":"getProxy","type":"->","class":"Doctrine\\Common\\Proxy\\AbstractProxyFactory","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php","line":2677,"args":[]},{"function":"createEntity","type":"->","class":"Doctrine\\ORM\\UnitOfWork","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php","line":138,"args":[]},{"function":"hydrateRowData","type":"->","class":"Doctrine\\ORM\\Internal\\Hydration\\SimpleObjectHydrator","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php","line":48,"args":[]},{"function":"hydrateAllData","type":"->","class":"Doctrine\\ORM\\Internal\\Hydration\\SimpleObjectHydrator","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php","line":140,"args":[]},{"function":"hydrateAll","type":"->","class":"Doctrine\\ORM\\Internal\\Hydration\\AbstractHydrator","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php","line":756,"args":[]},{"function":"load","type":"->","class":"Doctrine\\ORM\\Persisters\\BasicEntityPersister","file":"/var/www/html/crm/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php","line":196,"args":[]},{"function":"findOneBy","type":"->","class":"Doctrine\\ORM\\EntityRepository","file":"/var/www/html/crm/vendor/friendsofsymfony/user-bundle/Doctrine/UserManager.php","line":68,"args":[]},{"function":"findUserBy","type":"->","class":"FOS\\UserBundle\\Doctrine\\UserManager","file":"/var/www/html/crm/vendor/friendsofsymfony/user-bundle/Model/UserManager.php","line":92,"args":[]},{"function":"findUserByUsername","type":"->","class":"FOS\\UserBundle\\Model\\UserManager","file":"/var/www/html/crm/vendor/friendsofsymfony/user-bundle/Model/UserManager.php","line":108,"args":[]},{"function":"findUserByUsernameOrEmail","type":"->","class":"FOS\\UserBundle\\Model\\UserManager","file":"/var/www/html/crm/vendor/friendsofsymfony/user-bundle/Security/EmailUserProvider.php","line":21,"args":[]},{"function":"findUser","type":"->","class":"FOS\\UserBundle\\Security\\EmailUserProvider","file":"/var/www/html/crm/vendor/friendsofsymfony/user-bundle/Security/UserProvider.php","line":45,"args":[]},{"function":"loadUserByUsername","type":"->","class":"FOS\\UserBundle\\Security\\UserProvider","file":"/var/www/html/crm/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php","line":83,"args":[]},{"function":"retrieveUser","type":"->","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\DaoAuthenticationProvider","file":"/var/www/html/crm/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php","line":70,"args":[]},{"function":"authenticate","type":"->","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvider","file":"/var/www/html/crm/app/cache/prod/classes.php","line":3077,"args":[]},{"function":"authenticate","type":"->","class":"Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationProviderManager","file":"/var/www/html/crm/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php","line":96,"args":[]},{"function":"attemptAuthentication","type":"->","class":"Symfony\\Component\\Security\\Http\\Firewall\\UsernamePasswordFormAuthenticationListener","file":"/var/www/html/crm/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php","line":146,"args":[]},{"function":"handle","type":"->","class":"Symfony\\Component\\Security\\Http\\Firewall\\AbstractAuthenticationListener","file":"/var/www/html/crm/app/cache/prod/classes.php","line":2992,"args":[]},{"function":"onKernelRequest","type":"->","class":"Symfony\\Component\\Security\\Http\\Firewall","file":"/var/www/html/crm/app/cache/prod/classes.php","line":2245,"args":[]},{"function":"call_user_func:{/var/www/html/crm/app/cache/prod/classes.php:2245}","file":"/var/www/html/crm/app/cache/prod/classes.php","line":2245,"args":[]},{"function":"doDispatch","type":"->","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","file":"/var/www/html/crm/app/cache/prod/classes.php","line":2178,"args":[]},{"function":"dispatch","type":"->","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","file":"/var/www/html/crm/app/cache/prod/classes.php","line":2339,"args":[]},{"function":"dispatch","type":"->","class":"Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher","file":"/var/www/html/crm/app/bootstrap.php.cache","line":3083,"args":[]},{"function":"handleRaw","type":"->","class":"Symfony\\Component\\HttpKernel\\HttpKernel","file":"/var/www/html/crm/app/bootstrap.php.cache","line":3056,"args":[]},{"function":"handle","type":"->","class":"Symfony\\Component\\HttpKernel\\HttpKernel","file":"/var/www/html/crm/app/bootstrap.php.cache","line":3207,"args":[]},{"function":"handle","type":"->","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","file":"/var/www/html/crm/app/bootstrap.php.cache","line":2429,"args":[]},{"function":"handle","type":"->","class":"Symfony\\Component\\HttpKernel\\Kernel","file":"/var/www/html/crm/web/app.php","line":28,"args":[]},{"function":"{main}","file":"/var/www/html/crm/web/app.php","line":0,"args":[]}]} []
[2015-06-24 13:47:11] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Compile Error: require(): Failed opening required '/var/www/html/crm/app/cache/prod/doctrine/orm/Proxies/__CG__dmMembreBundleEntityMembreAuth.php' (include_path='.:/usr/share/pear:/usr/share/php')" at /var/www/html/crm/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 209 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 0): Compile Error: require(): Failed opening required '/var/www/html/crm/app/cache/prod/doctrine/orm/Proxies/__CG__dmMembreBundleEntityMembreAuth.php' (include_path='.:/usr/share/pear:/usr/share/php') at /var/www/html/crm/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209)"} []
Off course i first think about chmod on my cache directory but evrything is on 777 recursivly... and working like a charm if i dont set the debug on false!
So if anyone have an idea...

Found the answer
Before go on prod, we need to warm the prod cache to completely delete so before delete of the cache folder we have to execute this command:
php app/console cache:warmup --env=prod --no-debug
and after:
rm -rf app/cache/*; chmod -R 777 app/cache
And that's all folks!

Related

Symfony 4 - php bin/console server:run not works

I have a problem with this command : php bin/console server:run on Symfony 4
When I go to http://127.0.0.1:8000/ I have this error message :
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'J:\my_project\vendor\symfony\web-server-bundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
Indeed, the router.php file does not exist !
But if I run this command : php -S 127.0.0.1:8000 -t public everything is ok.
Any idea ?
First check that you have installed the SF4 Web Server bundle :
> composer require server --dev
then you can start using it through Symfony using run / start command
Not sure if this is the case for you too, but it is probably worth checking (and may also be interesting for others having the same problem).
My antivirus software likes to put the router.php in quarantine (effectively removing it from that directory). Check if yours did the same and if so restore it and create an exception for that file. Additionally you should configure your antivirus to notify you if it puts something in quarantine, so you can intervene in time.

Having issue on installing symfony doctrine-migrations-bundle

While I run command php composer.phar update it shows the following error. Can anyone help me out for fix it?
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Call to protected DoctrineORMEntit
yManager_000000001f94ab4b000000005d7f3b02e5139c916d21af4abfe5ffe5dd20d49e::__construct() from context 'appDevDebugProjectCon
tainer' in /var/www/html/app/cache/dev/appDevDebugProjectContainer.php:747
Stack trace:
#0 /var/www/html/app/bootstrap.php.cache(2125): appDevDebugProjectContainer->getDoctrine_Orm_DefaultEntityManagerService()
#1 /var/www/html/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ManagerRegistry.php(35): Symfony\Component\DependencyInj
ection\Container->get('doctrine.orm.de...')
#2 /var/www/html/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php(231): Symfony\Bridge\Doc
trine\ManagerRegistry->getService('doctrine.orm.de...')
#3 /var/www/html/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php(54): Doctrine\Common\Pe
rsistence\AbstractManagerRegistry->getManagers()
#4 /var/www/html/vendor/symfony/symfony/src/Symfony/Compo in /var/www/html/app/cache/dev/appDevDebugProjectContainer.php on
line 747
First remove the bundle from your composer.json.
Then try :
// replace app by var depending on your symfony version (2 or 3)
rm -Rf app/cache
// clean all your dependencies
rm -Rf vendor
// reinstall them from your composer.lock
composer install
// install this particular bundle
composer require doctrine/doctrine-migrations-bundle "^1.0"

Bootstrap 3 in Symfony2

I'm trying to use bootstrap in my symfony project . But when I configure json file through this error. However I have included
new Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle()
I have looked up from here
error:
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:
PHP Fatal error: Class 'Braincrafted\Bundle\BootstrapBundle\BraincraftedBo
otstrapBundle' not found in /home/kanat/Public/bootstrap/app/AppKernel.php
I have looked up from here
like the error says, its having touble clearing the cache, that could be a directory permission issue,set the folder permissions to read write and execute and then try to clear cache again, (in linux it would be sudo chmod -R 777 *)

Symfony2 Bootstrap.php.cache

I'm developing in Ubuntu 14 and I get the following error when creating a databaes:
$ php app/console doctrine:database:create
This is the error output:
PHP Warning: require_once(/home/jesse/playground/www/symfony/htdocs/app/bootstrap.php.cache):
failed to open stream: No such file or directory in
/home/jesse/playground/www/symfony/htdocs/app/console on line 10
PHP Fatal error: require_once(): Failed opening required
'/home/jesse/playground/www/symfony/htdocs/app/bootstrap.php.cache'
(include_path='.:/usr/share/php:/usr/share/pear') in
/home/jesse/playground/www/symfony/htdocs/app/console on line 10
What Ive Tried
Running this in Vagrant
Running this Locally
This is one among several problem running Symfony2 under Ubuntu, the other forcing you to implement umask(0000) otherwise you have to get chmod +a permissions for log and cache folders, this seems like a bit of a hassle for something seemingly simple.
Does anyone know what to work around this error?
This should do the trick:
php /home/jesse/playground/www/symfony/htdocs/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php

symfony2 load fixtures gives error, please advise on how to fix?

i am on part Updating the blog entity where i need to load the fixtures with command:
$ php app/console doctrine:fixtures:load
but i get an error:
php app/console doctrine:fixtures:load
> purging database
> loading Blogger\BlogBundle\DataFixtures\ORM\BlogFixtures
> loading Blogger\BlogBundle\DataFixtures\ORM\CommentFixtures
[ErrorException]
Warning: file_put_contents(/home/helloises/symfony2/Symfony/app/cache/dev/doctrine/orm/Proxies/Blogge rBlogBundleEntityBlogProxy.php): failed to open stream: Permission denied in
/home/helloises/symfony2/Symfony/vendor/doctrine/lib/Doctrine/ORM/Proxy/ProxyFactory.php
line 155
please help?
thanks
This is a permission error:
You don't have the write permission in the app/cache/dev/doctrine/orm/Proxies directory of your project so doctrine fails to create its proxy classes.
Maybe you gave the write permission to your HTTP server user (so the web works) but not to the user you used to execute the command.
See the Setting up Permissions paragraph in http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Resources