Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

danimohamadnejad's avatar

How to boot laravel 11 inside a php file

I am running a php file through terminal like: php file.php. the file is inside of laravel 11 project root directory. How can I boot laravel 11 app inside of this file manually so that I can use laravel different modules like Eloquent for example?
Something like: User:get() ?

0 likes
2 replies
Armani's avatar

@danimohamadnejad I'm not sure what are you trying to do but if you want to interact with database using terminal, you can use Tinker like this:

php artisan tinker
User::get()
Snapey's avatar

I would seriously suggest you create an artisan command and then put the logic from your php file in there, where you will have full access to the framework.

Instead of php myphpfile.php you would run php artisan myphpfile

Please or to participate in this conversation.