Answer the question
In order to leave comments, you need to log in
How to change the environment (environment) in Symfony2?
I am new to Symfony. Faced a problem with the environment (production / development)
Locally everything works.
When accessing locally at
localhost/web/app.php
localhost/web/app_dev.php
the system works
But when accessing from an external address to app.php or app_dev.php I get the error
You are not allowed to access this file. Check app_dev.php for more information.
Tried running the command:
php app/console cache:warmup --env=prod --no-debug
I get an
error:
PHP Fatal error: Class 'Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener' not found in /vendor/symfony/symfony/ src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php on line 142
Perhaps I missed something.
How to correctly change the environment in Symfony2?
Answer the question
In order to leave comments, you need to log in
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80:: 1', '::1')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
app.php - here is the prod environment
app_dev.php - here is the dev environment, which should only be used for development on the local server.
Actually, it is in these files that the environment to use and access checks are specified (in particular, the check is only in app_dev.php).
regarding cache warmup errors, Run cache:clear and then cache:warmup.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question