mrjayviper
mrjayviper

Reputation: 2388

Page would not load when I use app.php (Symfony 2.7)

so I've been learning Symfony and I've been using using app_dev.php to view my pages and this works fine.

By accident, I used app.php and this gave me a 404 (see below for full error message).

My config files are still unchanged. And the only change I did is to allow remote access on app_dev.php. I commented out the section that checks if the HTTP client is coming from localhost. Only because I don't have a development environment setup on my Mac and I'm using the dev/test one we have.

Any ideas what I could be wrong? Thank you! :)

ps. I can provide more snippets of my config files just tell me which one.

my controller:

<?php
// src/AppBundle/Controller/DirectoryController.php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class DirectoryController extends Controller {
    /**
     * @Route("/directory/view/{labs}", defaults={"labs" = "*"})
     */
    public function viewAction($labs) {
        return $this->render(
                "directory/view.html.twig"
                );
    }
}

my twig file:

{% extends 'base.html.twig' %}

{% block title %}My cool blog posts{% endblock %}

{% block body %}
    <h2 class="entity">TEST</h2>
{% endblock %}

error message:

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. 

Upvotes: 0

Views: 489

Answers (2)

Rvanlaak
Rvanlaak

Reputation: 3085

Are you sure your .htaccess file has DirectoryIndex set to app.php? If that's the case, the URL you are trying to open doesn't has to have that in it.

Upvotes: 0

Igor Pantović
Igor Pantović

Reputation: 9246

You need to warmup the cache so that it picks up new routes: app/console cache:clear --env=prod. Symfony does that automatically for dev environment (app_dev.php) but will not do it in production because of performance consequences it would have.

Upvotes: 3

Related Questions