laravel / tinker

Powerful REPL for the Laravel framework.
https://laravel.com/docs/artisan#tinker
MIT License
7.33k stars 130 forks source link

Error while migrating from Laravel tinker console #37

Closed ajthinking closed 5 years ago

ajthinking commented 6 years ago

While this works fine

Route::get('/', function () {
    \Artisan::call('migrate:fresh');
    return "ok";
});

Running

\Artisan::call('migrate:fresh');
\Artisan::call('migrate');
....

in tinker console results in all kinds of errors.

Steps to reproduce and clues as described here: https://stackoverflow.com/questions/48527840/error-while-migrating-from-laravel-tinker-console-sqlite

driesvints commented 5 years ago

This is because migrate:fresh isn't in the whitelist. Tinker maintains a whitelist for "safe" commands to be used with the shell: https://github.com/laravel/tinker/blob/master/src/Console/TinkerCommand.php#L19

driesvints commented 5 years ago

Just sent in a PR which should document how you can add commands to the Tinker shell. So you can actually add migrate:fresh etc if you want: https://github.com/laravel/tinker/pull/57