0
votes

I'm working on an imported project on Symfony 4.2 with Encore build system.

I installed all the module and everything is working fine.

But when I want to add a new page (requetes), I always get an 404 error.

Here is the project : https://github.com/LaboratoirePLH/ERC-MAP

  • PHP 7.2.11
  • PostgreSQL 9.6 with PostGIS 2.4
  • Symfony 4.2 with Encore build system
  • Bootstrap 4.2
  • jQuery 3
  • ChosenJS for jQuery (autocomplete combo box)
  • DataTables for jQuery (improved data tables)

I'm running PosteGre with Laragon.

I tried to ensure mod_rewrite on apache2.

I tried too to put an .httaccess file on the public/, still not working.

I checked the route with "php bin/console debug:route" and she is listed

https://i.imgur.com/p4naU6Z.png (I can't post the image I need more reputation)

The RequetesController.php :

/**
     * Page queries
     *
     * @Route("/requetes", name="requetes")
     */

     public function index(){

         return $this->render('requetes/index.html.twig');

     }

And the twig, in the requetes folder :

<html>
    <body>
        <h1>Hello {{ $requetes }}</h1>
    </body>
</html>

With the link "https://127.0.0.1:8000/requetes" I got a 404 error, and with "https://127.0.0.1:8000/" it's working.

I'm a beginner on Symfony and I really need your help.

3
Maybe because your templates doesn't exist in the place 'templates/requetes/index.html.twig' ?Nelson Rodrigues Marreiros
can you post the contents of config/routes/annotations.yaml and/or config/routes.yamlArleigh Hix
Thanks for your help ! My template exist in the right place, I checked this before testing any solution. Here is the content of the config/routes.yaml : i.imgur.com/Xla0USA.pngAleridia

3 Answers

0
votes

What you can try it's to call your twig like that :

return $this->render('requetes');

if it exists it have to display the page. If it exists can you show us the full error message ?

0
votes

In your project directory create this file if it does not exist : project_dir/public/.htaccess and add the following content to the file

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /index.php/
    </IfModule>
</IfModule>

0
votes

What is the content of your public/.htaccess file? Could you try with this one which come from the apache-pack recipe :

https://github.com/symfony/recipes-contrib/blob/master/symfony/apache-pack/1.0/public/.htaccess


EDIT :

Try to reformat your annotations ans action like this:

/**
 * Page queries
 *
 * @Route("/requetes", name="requetes")
 */
public function index()
{
    return $this->render('requetes/index.html.twig');
}