In Symfony2, when accessing my application locally via app_dev.php, everything works fine. However, when I access app.php it 404s:
Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for
A fresh symfony 2 install does not contain any routing for the production environment.
If you take a look under app/config/routing_dev.yml
, you will notice that all of the routes that you see in the demo application are defined only for development. If you wish to test the demo on app.php
, you have to first copy the routing from routing_dev.yml
to routing.yml
, and also enable the AcmeDemoBundle
under you AppKernel.php
:
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
+ new Acme\DemoBundle\AcmeDemoBundle()
}
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
- $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
(+ is the line you should add, - is the line you should remove)
I had the same problem and I just cleared the cache. php app/console cache:clear --env=prod
This has solved my problem.
Do not put the attribute to true: $ kernel = new AppKernel ('prod', TRUE);
it will activate the debug mode and it is not recommended for the prod.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With