dgdavidson's avatar

Route doesn't work on test server

I have one route that works on my local machine but not on a Forge/Linode install. Just one route in particular gives a NotFoundHttpException .

What possible reasons are there for something like this? Code is the same, permissions are the same.

Route::group(['prefix' => 'user'], function() {
    Route::get('profile', 'UserController@show');
    Route::post('profile', 'UserController@update');
});
0 likes
11 replies
tisuchi's avatar
  1. Make sure that you are uploading all the files...
  2. Folder needs to have necessary permissions.
1 like
Snapey's avatar

Its often a letter case mismatch, ie, the filename is usercontroller.php or similar. This can be an issue if you move from a case-insensitive environment to a case sensitive one.

The other thing to try is clearing the caches.

ie composer dump

and

php artisan route:cache

1 like
dgdavidson's avatar

Permissions all look good, files are all there. Code all looks the same.

composer dump and php artisan route:cache didn't help.

Letter case mismatch is a good idea but I don't see any differences. Will have to look at this closer.

simondavies's avatar

whats the url your using its it:

http:www.domain.dev/profile

or

http:www.domain.dev/user/profile

Could it be that your try the first url but its the actual second url as you have a prefix attached??

dgdavidson's avatar

Regarding case mismatch, I have purposely tried changing case in the class names, file names, URL and in the routes and the only way I can get a not found exception is by upper casing the prefix in the route group

Route::group(['prefix' => 'User'], function() {

instead of

Route::group(['prefix' => 'user'], function() {

and this is the code directly copied from the server

Route::group(['prefix' => 'user'], function() {

One other note, I am using caffinated modules, but this is the only route that I'm having trouble with.

simondavies's avatar

might a shot in the dark but add a /on the routess like

Route::group(['prefix' => 'user'], function() {
        Route::get('/profile', 'UserController@show');
     Route::post('/profile', 'UserController@update');
});
simondavies's avatar

Sorry, also which rout is it you say one, is it the post or get one, either way try adding

    ['uses' => 'UserController@update']

So

Route::group(['prefix' => 'user'], function() {
        Route::get('/profile', ['uses' => 'UserController@show']);
        Route::post('/profile', ['uses' => 'UserController@update']);
});
dgdavidson's avatar

So I tried to do a closure to get the controllers out of the picture

Route::group(['prefix' => 'user'], function() {
    Route::get('/profile', function(){
        return 'user profile';
    });
});

Still no luck...

dgdavidson's avatar
dgdavidson
OP
Best Answer
Level 7

I just uninstalled/reinstalled the repository using Forge and now it's working. Seems like one of the composer/artisan commands that were run should have fixed this but any, it's good now.

Please or to participate in this conversation.