laravel / tinker

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

[2.x] Add --execute option to console command #89

Closed jerguslejko closed 4 years ago

jerguslejko commented 4 years ago

This PR adds --execute option to the php artisan tinker command.

The idea is that by running php artisan tinker --execute="dump(config('database'))", you can use tinker non-interactively.

This allows the user to use tinker somewhat programmatically. It is extremely helpful in environments where an interactive shell is not available. Laravel Vapor for example. Debugging Vapor deployments becomes much easier.

StanAngeloff commented 4 years ago

You should already be able to pipe stdin to Tinker and it will execute it interactively:

echo "dump(config('database'))" | php artisan tinker
GrahamCampbell commented 4 years ago

You should already be able to pipe stdin to Tinker and it will execute it interactively:

The OP says their use case is Laravel Vapor. It's not clear to me if piping from stdin is easy there?