Package Data | |
---|---|
Maintainer Username: | sjones6 |
Maintainer Contact: | jones.spencera@gmail.com (Spencer Jones) |
Package Create Date: | 2016-11-15 |
Package Last Update: | 2016-11-19 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:16:56 |
Package Statistics | |
---|---|
Total Downloads: | 7 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This package allows for editing of stub templates, stub groups (to switch in and out of stub templates), and generating resourceful stubs (i.e., route, controller, model, views, model factory, migration, seeder, and test) with one command.
The center of SiegeLi is the resource and the mvc command. It generates all the boilerplate for resourceful interaction (CRUD) and persisting that resource to your database.
Requires Laravel 5.
Require the package into your project.
Add the service provider to your providers array in config/app.php
:
// Package Providers
SiegeLi\SiegeLiServiceProvider::class,
//
Publish the package: artisan vendor:publish
. This will add a stubs
directory to your resources
directory, and a configuration file called stubs.php
in your config
directory.
SiegeLi will work even if you don't publish the package. However, you will not be able to customize templates or configure the package for your project. But if you need to get up and running quickly on a standard Laravel install, you can skip this step.
If you're using a standard Laravel 5.3 file structure, SiegeLi should work out of the box. However, if anything is non-standard or you're using an older version of Laravel, edit the config/stubs.php
to reflect this. Specifically, you may need to indicate the path to your controllers or routes file.
For the resource name, it is best to use snake_case or spinal-case. The name will be converted to accepted standards (e.g., model name in StudlyCase).
artisan siege:m {resource-name} -m|--migration -s|--seeder -f|--factory
: make a modelartisan siege:v {resource-name} {view}
: make view (e.g., index, create, etc.) for a resourceartisan siege:c {resource-name} -r|--route
: make a controller for a resourceartisan siege:t {resource-name}
: make a test for a resourceartisan siege:mvc {resource-name}
: make resourceful MVC items (model, views, controller, routes, model factor, migration, database seeder, tests)For each of the above commands, you can also pass the following optional parameters:
-o|--options=
: stub template groups to include when generating stubs. See below on stub blocks.-a|--all
: include all optional resources (e.g., a model would also include migration, seeder, and factor) and optional template groups-g|group
: use a certain stub template group (see below on groups)When you publish the package, you will have a stubs
folder in your resources
directory. You can edit these at will.
Stubs use a simple syntax for populating variables and include/excluding template blocks.
Variables are wrapped in double curly braces, without spaces, and without dollar sign.
use {{namespace}}\User;
The following stub variables are available for use in any template:
Stub template blocks are between <<<block-name
and >>>
. Blocks can be included or excluded conditionally using -o|--option
parameter. For instance, running a stub command with -o siege
on the following would include all siege
blocks and exclude all !siege
blocks:
<<<siege
protected function thisWillBeIncluded()
{
//
}
>>>
<<<!siege
protected function thisWillBeExcluded()
{
//
}
>>>
You can also pass the -a|--all
option to include all optional template blocks.
Groups provide a convenient way switch between stub templates given the needs of your project or individual preferences.
Generate a stub group with the command artisan siege:group {group_name}
. For example, artisan siege:group test
will create a directory resources/stubs/test
populated with stubs. If you want to use another group as the base for this new stub group, add the -f|--from
option.
You then will need to add the stub group to config/stubs.php
file.
'siege' => 'base/',
'test-group' => 'test/'
Now you can use the name test-group
to access all of the stubs in the test
directory.
You can set a default template group in config/stubs.php
or indicate which group by passing a group name with the -g|--group
option, like so:
php artisan siege:mvc Test -g test-group