I am trying to use RESTful controller. Here is my Route.php
:
Route::resource(\'test\', \'TestController\');
Route::get(\'/\', function()
{
r
another thing to check is your document root,
mine was:
www/var
and should be:
www/var/mysite/public
Another reason why I hate web development
Before my web.php
was like below
Route::group(['prefix' => 'admin', 'middleware' => ['role:admin']], function() {
Route::resource('roles','Admin\RoleController');
Route::resource('users','Admin\UserController');
});
In url enterd
http://127.0.0.1:8000/admin/roles
and get the same error. The solution was :
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('roles','Admin\RoleController');
Route::resource('users','Admin\UserController');
});
Remove 'prefix' => 'admin', as both Controllers are located in Admin folder
Put this in root .htaccess
file
The below code do three things :
Note : RewriteRule ^ index.php [L]
this code solve your problem my problem was not added [L]
after index.php
RewriteEngine On
<IfModule mod_rewrite.c>
#Session timeout
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymlinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
In my case the problem was that i called the wrong route in postman.
Wrong route : http://localhost:8000/methodName
Correct route : http://localhost:8000/api/methodName
I forgot to add "/api".
I have found another situation where this error can occur, and that one has nothing todo with rewrites, for once. It's a very nasty typo :)
I had:
Route::get('replicas/item/{id}/{?stub}', ['uses' => 'ProductReplicasController@productview', 'as' => 'database.replicas.productview']);
see the {?stub}, that caused this error with me, it needs to be {stub?} off course. But if you're new to Laravel (like me), that is very easy to miss and could take quite some time to figure out. :)
like Arjan Koole says, I had a similar error
using:
Route::get('/performance/{$submit_type}/{$send_selected}/{$date_a}/{$date_b}', 'PerformanceController@calc');
instead of
Route::get('/performance/{submit_type}/{send_selected}/{date_a}/{date_b}', 'PerformanceController@calc');
So be aware when you use {$stuff}