I recently hosted a laravel project (for a customer) on shared hosting, after failed attempts to get access to the server via ssh I contacted the host who informed me that ssh
You can easily create a small Artisan script within PHP like this:
Artisan::call('migrate');
This equals php artisan migrate
. Use it anywhere you want to run your migrations.
If you are in production mode (if APP_ENV=production
inside your .env
file) then you would have to force the migration in case you want to allow to make changes. You can do it as follows:
Artisan::call('migrate', ["--force" => true ]);
This equals adding the --force flag a la php artisan migrate --force
.
To answer your specific question though, create a route like this:
Route::get('/run-migrations', function () {
return Artisan::call('migrate', ["--force" => true ]);
});
If you are interested in creating a web installer, you might be interested in this package:
https://github.com/Froiden/laravel-installer
Check out the code to see how he handles migrations and seeds etc.