Interact with your application using artisan tinker


Another cool feature in laravel is the ability to interact with your application via artisan tinker, using artisan tinker you can execute php code and interact with your application code.

You can enter artisan tinker mode, by running the artisan command like this:
php artisan tinker

Once you are on artisan tinker mode, you can execute any php code and also you can execute code that are related to your laravel application.

As an example, let's try to show database config on your laravel application, here's the command:
print_r(Config::get('database.connections.mysql'));

Another example is to run eloquent query, like this:
$user = User::get(); print_r($user->toArray());

You can try anything you want with artisan tinker, the sky is the limit, just remember that artisan tinker is case sensitive, if you get an error just make sure you type it correctly.


EmoticonEmoticon