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.

artisan 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.

HTML code

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.

Visit our blog

Overcoming the Challenges of Working With a Mobile FinTech API

Andela community member Zzwia Raymond explores why, despite the potential of the MTN Mobile Money platform and its API, there are technical hurdles, from complex documentation to enhancing functionality.

How Andela Transformed Tech Hiring in 10 Years

Celebrating 10 years of transforming tech hiring by unlocking global talent across Africa, Latin America and beyond, Andela has surpassed its original goal by training nearly 110,000 technologists and assembling one of the world's largest remote tech talent marketplaces.

What GPT-4o and Gemini releases mean for AI

The latest generative AI models from OpenAI (GPT-4) and Google (Gemini 1.5 Pro, Veo, etc.) promise improved capabilities, lower costs, and transformative applications across various industries by integrating advanced AI technologies into business operations.

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.