Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Rest Controller Format Request 404
Hi, i'm studying the rest controller. I'm reading this documentation page:
I'm testing the example of the controller "test" at anchor:
My local configuration is latest stable fuelphp 1.8 on local PHP server.
It's PHP local server at port 8000, as documentated here:
Thus, if i request:
I get the right response in HTML format.
But when i request:
I get 404 error page.
The route config class is standard:
'_root_' => 'user/index', // The default route
'_404_' => 'welcome/404', // The main 404 route
'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
How can i get json format response?
Don't use PHP's local server in that way, but use
php oil server [help]
in the root of your fuel installation (there where the oil script is). If you just load index.php, you miss the required functionality that is in .htaccess, which rewrites the request URL to something Fuel can use.
... Now it's running oil server, thanks:
francesco@ulisse:~/local/microblog/web$ php oil server
Document root is public
Press Ctrl-C to quit.
[Wed Jul 12 10:09:17 2017] 127.0.0.1:40518 : /
Fuel\Core\FuelException [ Error ]:
Could not find asset: bootstrap.css
COREPATH/classes/asset/instance.php @ line 413
Doesn't it display a trace log?
The server also outputs what URL it is processing, and what files are returned.
I've just tested "php oil server" on one of our apps (one that normally runs under nginx, picked randomly), and that works file, albeit a tad slow...
In local's console:
It gets there because it still goes to the 404 page.
How are you checking, using a browser? If so, the HTTP_ACCEPT from the browser header will override the json extension, if you want to skip that, you need to set "ignore_http_accept" to true in the rest.php config file in app/config.
... thanks for your patience.
I'm checking using a browser and using cli by wget, curl. But the result is: 404 error.
I'was checking ignore_http_accept to true value, so i get the XML default format without extension.
I loaded the code on production server and all is ok.
Thus the problem is relative to local server.
Weird. Good you've got it sorted though.
Harro, IMHO the problem Is in local server's port notation of the URL.
You mean that if you start 'php oil server' as root on port 80, it does work fine? And if you use
. it fails again?
In other words, is it related to the port number, or to the way the commandline server parses the request?
... to the port number. Oil
works at port 8000:
Production server at the port 80, but without URL's suffix ":80".
In my temporary test:
... to avoid suffix port I'm tring:
php oil server port=80
but I have same problem in the browser:
Thus the problem is not relative to URL's suffix port.
How do I debug this issue?
I'm checking with the fuelphp's profiling tool.
Here the result.
I have this:
I have this:
The main request URI is empty!
Ok, I can reproduce it, which means I can now debug it.
Turned out to be an easy fix:
Many thanks, Harro!
It's ok for me!
I notice that:
It works with default value (false) for '
ignore_http_accept' in Rest's configuration;
It works with default value (true) for 'strip_extension' in Fuel general config's routing settings.
Thanks for the feedback.
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion