Lumen artisan — Let us make

Pete Houston
2 min readApr 15, 2015

by Pete Houston

Note: as of Laravel Lumen 5.0.2 update, the “artisan make” is removed completely. So you don’t need to read more on this article!!

In my previous article, I’d already shown you the first look at the Lumen micro-framework, including part about artisan command.

In this article, let’s dig a bit deeper about the make command then.

First, you can try to get some help from artisan about “make”.

$ php artisan help makeUsage:
make name
Arguments:
name The section of the application to scaffold
Options:
— help (-h) Display this help message
— quiet (-q) Do not output any message
— verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
— version (-V) Display this application version
— ansi Force ANSI output
— no-ansi Disable ANSI output
— no-interaction (-n) Do not ask any interactive question
— env The environment the command should run under.

The question is that “What is -name-?”, what values can be given for the “name” options.

If you take a deeper look inside the code of the make command, you will see this part.

public function fire()
{
switch ($this->argument(‘name’)) {
case ‘foundation’:
$this->makeDatabase();
$this->makeResources();
break;
case ‘database’:
$this->makeDatabase();
break;
case ‘lang’:
$this->makeLang();
break;
case ‘resources’:
$this->makeResources();
break;
case ‘views’:
$this->makeViews();
break;
default:
throw new \InvalidArgumentException;
}
$this->info(‘Directories created!’);
}

Alright, so “name” could be one of the five in [ foundation, database, lang, resources, views ]

Trace the code, you will notice the tasks of those name options:

  • foundation”: will trigger “database” and “resources”.
  • database”: will generate two directories “/database/migrations” and “/database/seeds”.
  • resources”: will trigger “lang” and “views”.
  • lang”: will generate directory “resources/lang/en” and one file in it “resources/lang/en/validation.php” with basic configuration.
  • views”: will generate directory “resources/views”.

As mentioned before, by default installation, Lumen doesn’t have the “database” and “resources”; they will be created if developers really feel the necessities for the project.

Though, the “artisan make” command provides the convenient way to generate those directories and files, we still can create them manually. There is absolutely no problem!

Hope you get the idea of how it works in this article.

Happy Lumen-ing ☺

--

--