laravel / tinker

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

Artisan::call is broken in tinker #181

Closed netpok closed 1 month ago

netpok commented 1 month ago

Tinker Version

2.9.0

Laravel Version

11.19.0

PHP Version

8.3.9

Database Driver & Version

MySQL 8.0.37 on Linux

Description

Artisan calls are not working as expected, two examples:

These commands are running successfully when called like php artisan down --quiet or php artisan migrate --seed.

Also the same happens when they are indirectly called (e.g. $model->restore() is called in tinker and an event listener executes the Artisan::call('migrate --seed'); line.

Steps To Reproduce

Take a brand new Laravel install and run Artisan::call('migrate --seed') or Artisan::call('down --quiet') in tinker.

github-actions[bot] commented 1 month ago

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

fbcarpinato commented 1 month ago

I investigated a little bit the migrate --seed command and it breaks because it tries to calls the migrate command class and internally it calls the db:seed command which breaks because it's not on the whitelist of commands inside TinkerCommand, i tried to add db and db:seed in the whitelist and it looks like it works.

I don't really know why they where not added in the first place, maybe @driesvints can explain it better.

yoonustehrani commented 1 month ago

I investigated a little bit the migrate --seed command and it breaks because it tries to calls the migrate command class and internally it calls the db:seed command which breaks because it's not on the whitelist of commands inside TinkerCommand, i tried to add db and db:seed in the whitelist and it looks like it works.

I don't really know why they where not added in the first place, maybe @driesvints can explain it better.

Same here I first published the tinker config file and added Illuminate\Database\Console\Seeds\SeedCommand::class inside its commands array and Artisan::call('migrate --seed') worked without nagging.

But the issue with down --quiet is still unknow to me.

yoonustehrani commented 1 month ago

Ah there it is ! If we take a look at Illuminate\Foundation\Console\DownCommand there is no --quiet option in there! The --quiet option is added by Laravel itself.

driesvints commented 1 month ago

Thanks @yoonustehrani. @netpok feel free to add the command to the config file if you need it in Tinker.