Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

santiago.correa.e's avatar

My project doesn't work

I have a laravel project and it works just fine in my localhost but when I try to run it in a cloud hosting only show me the home page, when I try another one this error is shown:

MethodNotAllowedHttpException in RouteCollection.php line 251:

I think is a problem with the routes what I don't get is why is working locally?

thank for any help

0 likes
5 replies
vmitchell85's avatar

I think you'll need to post a bit more information. Maybe your routes file and the route you're trying to hit.

I'd also check the following:

  • Did you run composer install
  • Did you migrate your database?
  • Did you setup your .env file?
  • Did you run php artisan key:generate for the .env key?

Hope this helps...

santiago.correa.e's avatar

here are my routes:

Route::get('/', 'SessionController@create'); Route::post('/', 'SessionController@store'); Route::get('/logout', 'SessionController@destroy');

Route::get('/cliente', function () { return view('sessions.homeCliente'); }); Route::get('/staff', function () { return view('sessions.homeStaff'); });

and the methods create and store in my sessioncontroller:

public function create(){

    return view('sessions.create');

}
public function store(){
    //intento de iniciar session


    $request=request(['usuario','password']);


    if(!auth()->attempt($request)){

            return redirect('/prueba');
    }

    //redirigir a donde se necesite

    if(User::getCliente($request['usuario'])==0){

        return redirect('/staff');

    }

    return redirect('/cliente');

}

I Do not have access as root because is a sharing hosting, so I can not run composer install, is that why is not working?

another think, the "home page" is in thihs route "http://sioma.site/laravel_sioma/public/" beacuse this is for testing, si I can not just put the files in laravel's public folder into the public folder in the hosting.

If you need any other info just let me know.

Snapey's avatar
Snapey
Best Answer
Level 122

And there's your problem

Your routes are all expecting to be in the root folder of the server.

When you click the route for /cliente it is trying to access http://sioma.site/cliente which is obviously wrong.

because you have published all your credentials to the web, I suggest you take the site down again (delete it) and then change your passwords;

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mo***********as
DB_USERNAME=root
DB_PASSWORD=root

You should never publish your laravel code into a public folder.

Check this post for the reason https://laravel-news.com/subfolder-install

1 like
santiago.correa.e's avatar

@snapey , I get what you say, but this is only a development site, at the end everything is going to another site, and the passwords would change and only the public thing will be on public_html.

so I already try clicking the route /laravel_sioma/public/cliente, and still the same error.

ok now I follow the subfolder tutorial, and it doesn't found my user controller, this error is shhown:

FatalErrorException in EloquentUserProvider.php line 136: Class '\laravel_sioma\App\user' not found

Please or to participate in this conversation.