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.
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!