1

I have gone through many questions related to this in SO, but couldn't find a solution to my problem.

I have copied the demo symfony application to /var/www/html/myproject folder. I can only access the localhost/myproject/web/app_dev.php but not localhost/myproject/web/app.php . Basically I want to switch from development environment to prodution environment.

I just get a blank page when I access app.php. How do I solve this issue?

Following is my routing.yml file

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

EDIT

Error log (app/logs/prod.log)

[2015-04-06 22:54:53] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /"" at /home/fazlan/ppp/myproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 144 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /\" at /home/fazlan/ppp/myproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:144, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/fazlan/ppp/myproject/app/cache/prod/appProdUrlMatcher.php:35)"} []

2 Answers 2

1

You need to create your bundle and configure routes for it. After this prod environment will be work. It is possible that the acme isnt work in prod.

@Cedric: Acme Demo Bundle is only configured on app_dev.php you have to create another bundle first with proper routes, you can see the list of routes for your bundle in app/config/routing.yml or whatever you set as a the extension of your configs.

More info here.

Sign up to request clarification or add additional context in comments.

9 Comments

Do u have any bundles? Looks like u dont have routes. Try to use routes for acmedemobundle.
yes the default, Acme bundle. The problem is the application works with dev environment(app_dev.php) but not with app.php
Thats all! You need to create your bundle and configure routes for it. After this prod environment will be work. It is possible that the acme isnt work in prod. Read doc here
i'm sorry, what was the solution again?
Acme Demo Bundle is only configured on app_dev.php you have to create another bundle first with proper routes, you can see the list of routes for your bundle in app/config/routing.yml or whatever you set as a the extension of your configs
|
0

After going through different tutorials and manuals, I finally was able to solve this issue by the following changes.

routing.yml

app:
    resource: "@AppBundle/Controller/"
    type:     annotation


_acme_demo:
    resource: "@AcmeDemoBundle/Resources/config/routing.yml"

AppKernel.php (The whole file is not shown here)

public function registerBundles()
    {
        $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\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
             new Acme\DemoBundle\AcmeDemoBundle(),

        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            //$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

in the above file AcmeDemoBundle is registered. You have to comment out //$bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); to prevent the bundle being registered twice in dev and test environments.

After editing those two files go to the project folder and do

php app/console --env=prod cache:clear

and then in the browser localhost/myproject/web/app.php would load the same bundle as in app_dev.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.