README.md

Laravel Craftsman

Description

Laravel Craftsman (written using the awesome Laravel-Zero CLI builder) provides a suite of crafting assets using a project agnostic CLI.

You can quickly create class, controller, factory, migration, model, form-request, resource, seed and view assets.
In addition, you can create all assets with a single command, allowing you to quickly craft a new resource in seconds!

Commands

The following commands are available in any Laravel project. You can use the individual crafting routines which are similar to the Artisan commands, but the craft:all command is the most powerful of the bunch.

Using craft:all you can easily generate all assets (controller, factory, migration, model, and seed) for a given resource (ie Post, Customer, etc)

🚨 If you have spaces separating fields, you must surround fields list in quotes

--down, -d

Include down methods (skipped by default)

--template, -t

Path to custom template (override config file)

--overwrite, -w

Overwrite existing class

craft:model

model name

Creates model using supplied options

See below about defining alternate model path

--tablename, -t

Tablename used in database (will set $tablename in Model)

If not supplied, default table will be pluralized model name

--template, -m

Path to custom template (override config file)

--overwrite, -w

Overwrite existing class

craft:request

request name

Creates form request using supplied options

See below about defining alternate model path

--rules, -r

List of rules (optional)

🚨 If you have spaces separating fields, you must surround rules lists in quotes

--template, -m

Path to custom template (override config file)

--overwrite, -w

Overwrite existing class

craft:seed

base seed name

Creates seed file using supplied options

--model, -m

Path to model (eg App/Models/Post)

--rows, -r

Number of rows to use in factory call (Optional)

--template, -t

Path to custom template (override config file)

--overwrite, -w

Overwrite existing class

craft:views

base resource

Creates view files

--extends, -x

Includes extends block using supplied layout

--section, -s

Includes section block using supplied name

--no-create, -c

Exclude create view

--no-edit, -d

Exclude edit view

--no-index, -i

Exclude index view

--no-show, -w

Exclude show view

Defining Class Path

When crafting resources which are not automatically created in their assigned directories, you can define the location to the path where asset is created as follows:

> laravel-craftsman craft:class App/Services/Sync ...

This will create a class in the App/Services path, with filename Sync.php. Directories (including nested directories) will be created if they do not already exists.

Supported Commands:

The following commands support defining class path

craft:class

craft:factory

craft:model

craft:seed

craft:test

Single Use Template

In addition to the standard templates, you may also define a single use template which is only used during command execution. Single use templates are designed to reference project specific templates, and you use the <projet> keyword when executing the desire command.

Tips

Boolean Option Shortcut

When executing any of the laravel-craftsman commands, if you wish to apply one or more switches (those options which do not require a corresponding value), you can use the standard CLI shorthands (this tip can be used in any CLI based tool, not just laravel-craftsman (well assuming the CLI actually supports shorthand).

For example:

Lets assume you wish to wish to create views, you can use the following command to skip creation of the create (-c), edit (-d) and show (-w) views (only creating the index view). The combination of -cdw is shorthand for --no-create --no-edit --no-show

Defining Nested Paths

Any command can store assets within tested folders within default path by separating name argument with forward slash
For example, the following command will define the path for model asset in the App/Models/<name> path

> laravel-craftsman App/Models/Customer ...

Custom Templates

Laravel Craftsman provides support for creating custom templates if you wish to change the syntax to match your personal style. The default templates use the standard Laravel syntax, but we like to allow ou have your own flair.

User Customized Templates

If you wish to create derivatives of the supported templates, you can customize the config.php located in the laravel-craftsman directory.
By default, this will be ~/.composer/vendor/codedungeon/laravel-craftsman, but may be different depending on the method you chose to install laravel-craftsman.

Single Use Template

In addition to creating templates and configuring the config.php file, you may optionally supply a template to be used as single use (not stored) from all command execution
For example, if you wish to create a standard class asset, you can use a single use template as follows: