Reputation: 181
I installed latest symfony2 and follow the book to install and setup everything.
Xampp is in /opt/lampp, symfony2 is in my home dir ~/proj/symfony2.
I made a symbol link /opt/lampp/htdocs/symfony2 => ~/proj/symfony2.
In browser, I type in "localhost/symfony2/web/app_dev.php". It works! the page shows up.
But if I used app.php instead, browser will be redirected to /opt/lampp/htdocs/index.
If I copy app_dev.php to app.php, still doesn't work!!! Why this happens?
If I copy app_dev.php to app_test.php and use "localhost/symfony2/web/app_test.php". It works!
I really don't know why it is so hard to make prod work in symfony2.
I read a lot of post about app.php get 404 error. And try clear, warmup, dump....nothing help.
I know acmedemo is for debug only. But how to test prod out of box? I do this because I follow book to write a acme hello but didn't work in prod. I put it to app_dev.php, didn't work.
app/prod.log: could be the reason?
request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/framework/images/input_bg.gif"" at /.../symfony2/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 94 [] []
Upvotes: 0
Views: 6552
Reputation: 1165
Be careful to dump()
function, I have prod env issues resolved by remove dump in few files (like repository files).
You can either check your apache configuration.
Upvotes: 0
Reputation: 181
Setup virtual host seems works for access app.php or app_dev.php
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias www.localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName myweb.local
ServerPath "/home/xxx/proj/myweb/symfony2/web"
ServerAlias www.myweb.local
UseCanonicalName Off
DirectoryIndex app.php
DocumentRoot "/home/xxx/proj/myweb/symfony2/web"
<Directory /home/xxx/proj/myweb/symfony2/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
#AllowOverride AuthConfig FileInfo
#Order allow,deny
Allow from all
Require local
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
ErrorLog "logs/myweb.local-error_log"
CustomLog "logs/myweb.local-access_log" common
Upvotes: 0
Reputation: 813
The Symfony2 Standard Edition comes with a complete demo that lives inside a bundle called AcmeDemoBundle.
This bundle available only for dev environment:
AppKernel.php
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
routing_dev.yml:
_welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index }
You should:
1) remove the AcmeDemoBundle http://symfony.com/doc/2.2/cookbook/bundles/remove.html
2) generating a new bundle http://symfony.com/doc/master/bundles/SensioGeneratorBundle/commands/generate_bundle.html
http://symfony.com/doc/master/book/routing.html
Upvotes: 3