3 Easy Steps to Make Laravel Tinker Work in Your Lumen App
Laravel Tinker is a great program, and it would be even better if you could use it with the Lumen app. Unfortunately that ability is not available inherently with the program, but these four easy steps can get you started with Tinker on Lumen.
Although the Laravel documentation on Artisan Console shows how to get started, it doesn’t discuss Lumen.
Step 1: Install Laravel Lumen using composer require laravel/tinker.

Step 2: Realize that you can’t use vendor:publish because it also doesn’t come preloaded with Lumen right out of the box. If you already have vendor:publish capability, go ahead and use the command to get Lumen running, congratulations, you’re done. Otherwise move on to Step 3.
Step 3: Make a tinker.php file in your config directory. Then copy and paste the code below into your config directory. (In the lucky event that you were able to run the vendor:publish command in Step 2, this file was already created for you.)
<?phpreturn [ /* |-------------------------------------------------------------------------- | Console Commands |-------------------------------------------------------------------------- | | This option allows you to add additional Artisan commands that should | be available within the Tinker environment. Once the command is in | this array you may execute the command in Tinker using its name. | */ 'commands' => [ // App\Console\Commands\ExampleCommand::class, ], /* |-------------------------------------------------------------------------- | Auto Aliased Classes |-------------------------------------------------------------------------- | | Tinker will not automatically alias classes in your vendor namespaces | but you may explicitly allow a subset of classes to get aliased by | adding the names of each of those classes to the following list. | */ 'alias' => [ // ], /* |-------------------------------------------------------------------------- | Classes That Should Not Be Aliased |-------------------------------------------------------------------------- | | Typically, Tinker automatically aliases classes as you require them in | Tinker. However, you may wish to never alias certain classes, which | you may accomplish by listing the classes in the following array. | */ 'dont_alias' => [ 'App\Nova', ],];
After this is loaded, you have to register the TinkerServiceProvider in the bootstrap/app.php file.
...$app->configure('tinker');...$app->register(\Laravel\Tinker\TinkerServiceProvider::class);
After following these steps, the Tinker command should now be usable in your Lumen app. In the event that there was a problem, try a simple composer dumpautoload to resolve the issue.

Have fun using Laravel Tinker in the Lumen app, and be sure to share this tutorial with all your friends!
Are you a Laravel developer looking for your next role? Apply to join the Andela Talent Network today.
Related posts
The latest articles from Andela.
.png)
Accelerate your ambition: 7 ways to spark career growth

The 6 most in-demand tech skills are also the hardest to find

Andela Research Finds Increasing Demand for Global Remote Tech Talent
We have a 96%+
talent match success rate.
The Andela Talent Operating Platform provides transparency to talent profiles and assessment before hiring. AI-driven algorithms match the right talent for the job.
