I'm trying to implement a REST API with symfony 4. My problem is that I can't reach my routes for my method GET and POST. Everytime I try, I get a 404 error.
But when I try to get my routes on symfony, I have :
Name Method Scheme Host Path
app_statistics_poststatistics POST ANY ANY /api/stat
app_statistics_getstatistics GET ANY ANY /api/stat/{statId}
So my routes does exist, but I can't reach them.
I'm working on a Windows Environment with WAMP to work in local.
I've already tried my api on 2 windows environnment and on one Linux environnment with LAMP. Always getting a 404 Not Found.
The author of the tutorial told me that my api was working on his computer, but I don't have more info about his environnment. So, I expect the problem to come from the configuration of my virtual host.
Here is my virtual host:
<VirtualHost *:80>
ServerName statroche.fr
ServerAlias www.statroche.fr
DocumentRoot "D:/other/symfony/testRoche/public"
<Directory "D:/other/symfony/testRoche/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Important note: I don't have anything in my public folder as I don't want any page, just the API, do I still need to put 'public' in DocumentRoot
and Directory
?.
I would like to reach my API and then for the GET method for example, return a json. Actually, I can reach the /
of my project but can't reach other routes.
Even if you don't want to build an "old-style website" with Symfony, you have to use index.php
to bootstrap Symfony and to make the API accessible