Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

symfony - Why is my Symfony2 install 404ing when I access app.php?

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

question from:https://stackoverflow.com/questions/6997543/why-is-my-symfony2-install-404ing-when-i-access-app-php

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 SymfonyBundleFrameworkBundleFrameworkBundle(),
        new SymfonyBundleSecurityBundleSecurityBundle(),
        new SymfonyBundleTwigBundleTwigBundle(),
        new SymfonyBundleMonologBundleMonologBundle(),
        new SymfonyBundleSwiftmailerBundleSwiftmailerBundle(),
        new SymfonyBundleDoctrineBundleDoctrineBundle(),
        new SymfonyBundleAsseticBundleAsseticBundle(),
        new SensioBundleFrameworkExtraBundleSensioFrameworkExtraBundle(),
        new JMSSecurityExtraBundleJMSSecurityExtraBundle(),
+       new AcmeDemoBundleAcmeDemoBundle()
    }

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
-       $bundles[] = new AcmeDemoBundleAcmeDemoBundle();
        $bundles[] = new SymfonyBundleWebProfilerBundleWebProfilerBundle();
        $bundles[] = new SensioBundleDistributionBundleSensioDistributionBundle();
        $bundles[] = new SensioBundleGeneratorBundleSensioGeneratorBundle();
    } 

(+ is the line you should add, - is the line you should remove)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...