Laravel Craftsman CLI

Laravel Craftsman CLI

Laravel Craftsman is a CLI for easily crafting Laravel assets for any project (artisan make on steroids) by Mike Erickson. This project relies on Laravel Zero, providing a suite of “project agnostic” CLI tools that you install globally:

composer global require codedungeon/laravel-craftsman

You can create all assets for a typical model/view/controller setup using the craft:all command:

laravel-craftsman craft:all Post \
  --model App/Models/Post \
  --tablename posts \
  --rows 50 \
  --extends \
  --section content

Take note that this command also takes care of extending the layouts/app.blade.php file in template files.

Here’s an example from the readme you can use to generate a migration file complete with the table definition using the --fields option:

--fields fname:string@25:nullable,lname:string@50:nullable,email:string@80:nullable:unique,dob:datetime,notes:text,deleted_at:timezone

# results in...
Schema::create('contacts', function (Blueprint $table) {
    $table->string('fname', 25)->nullable();
    $table->string('lname', 50)->nullable();
    $table->string('email', 80)->nullable()->unique();

The project also allows you to configure the templates used for the generated files with the Mustache templating language. Here’s an example of the class template at the time of writing:


namespace {{namespace}};

class {{model}}
    function __construct() {}

Check out the readme for the full list of commands and flags. You can also run laravel-craftsman list from the command line after you’ve installed the package globally and added it to your path. You can learn more about this package and check out the source code on GitHub at mikeerickson/laravel-craftsman.

Filed in: News / Artisan


Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Laravel Developer
FPV Exchange
Senior Full-Stack Developer
Remote, USA Only
Full Stack Web Developer
Greenville, TX (or Remote, US)
Innovation First International, Inc.
Senior Software Developer
UK/Germany Only
The Greenhouse People Ltd
Senior PHP Developer
Cary, NC