6

I've installed Symfony2 2.7 in C:\xampp\htdocs\sym1\blog, I created a new controller manually following this Document

   <?php
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;

class LuckyController extends Controller
{
    /**
     * @Route("/lucky/number")
     */
    public function numberAction()
    {
        $number = rand(0, 100);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}

but when i go to

http://localhost/sym1/blog/web/lucky/number

or

http://localhost/sym1/blog/app_dev.php/lucky/number

it just displays

Oops! An Error Occurred

The server returned a "404 Not Found".

Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

anyone knows what's the problem?

--update--

i'm just found comment this

 #RewriteRule .? %{ENV:BASE}/app.php [L]

and then add these two lines

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]

will ok, but there is a performance bar attached at the bottom of the page.

1
  • 1
    Run php app/console cache:clear --env=prod every time you want to see changes on production. Commented Sep 8, 2015 at 6:22

2 Answers 2

7

I think, you don't understand the concept of environments in Symfony2. In the first case Apache executed app.php from web folder. It is production version of your app. A lot of cached files that are not refreshed on each request. This is the reason why you don't see your changes. You have to clear a cache first by console command.

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

In second case, Apache executes app_dev.php. This is development enviroment. You see your changes immediately and also can see the developmnet toolbar which is very useful for development. Toolbar is present only in development enviroment.

http://symfony.com/doc/current/book/configuration.html#environments

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

Comments

1

Another possible solution:

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

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.