Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artisan::call is broken in tinker #181

Closed
netpok opened this issue Aug 2, 2024 · 5 comments
Closed

Artisan::call is broken in tinker #181

netpok opened this issue Aug 2, 2024 · 5 comments

Comments

@netpok
Copy link

netpok commented Aug 2, 2024

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:

  • Calling migrate --seed results in error NAMESPACE NOT FOUND There are no commands defined in the "db" namespace.
  • Calling down --quiet results in INVALID OPTION The "--quiet" option does not exist.

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.

Copy link

github-actions bot commented Aug 2, 2024

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
Copy link

fbcarpinato commented Aug 2, 2024

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
Copy link

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
Copy link

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants