fbnkcmaster / appskeleton-for-laravel
为 Laravel 5 定制的 artisan 命令,可帮助您加速 Web 应用开发
1.0.0
2016-07-06 13:29 UTC
Requires
- php: >=5.5.9
- laracasts/generators: ~1.1.3
Requires (Dev)
- laravel/laravel: ~5.2.3
This package is not auto-updated.
Last update: 2024-09-14 19:31:10 UTC
README
AppSkeleton for Laravel 是一个定制的 artisan 命令,通过生成所需文件和目录的现成结构(基于 json 文件),可以帮助您加快应用程序开发速度
要求
- (可选) 如果您需要创建具有模式迁移的高级选项,您需要安装 laracasts/generators(由 Jeffrey Way 提供)。如果您使用 Composer 安装此包,它将自动完成,并且您需要在 app/Providers/AppServiceProvider.php 中添加其服务提供者
用法
步骤 1:通过 Composer 安装
$ composer require fbnkcmaster/appskeleton-for-laravel
步骤 2:注册命令
这需要在 app/Console/Kernel.php
文件中完成,如下所示
protected $commands = [ // add the line below to this array \FBNKCMaster\AppSkeletonForLaravel\AppSkeletonCommand::class ];
- 如果您手动下载并安装它,则必须在
app/Console/Kernel.php
文件中将 path/to/AppSkeleton/AppSkeletonCommand::class 设置为注册命令,如下所示
protected $commands = [ // add the line below to this array path/to/where/you/put/AppSkeleton/AppSkeletonCommand::class ];
-
可选
您需要安装 Jeffrey Way 的 laracasts/generators 以获得更高级的迁移选项。
然后在 app/Providers/AppServiceProvider.php 中添加其服务提供者,如下所示
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
}
}
步骤 3:完成!
现在您已经准备好了。从控制台运行 php artisan
,您将在 make:*
命名空间部分看到新的命令 make:appskeleton
。
示例
json 文件的示例
将 json 文件放置在可以从 artisan 命令访问的位置
{ "name": "App Name", "routes": [ {"get": "/:function () {return view('welcome');}"}, {"get": "home:HomeControler@index"}, {"get": "users/{user}:UsersController@show"}, {"post": "post:PostsController@store"}, {"post": "comment:CommentsController@store"}, {"resource": "post:PostsController"}, {"resource": "comment:CommentsController"} ], "controllers": [ {"name": "home"}, {"name": "dashboard"}, {"name": "users", "resource": false}, {"name": "posts", "resource": true}, {"name": "comments", "resource": true} ], "models": [ {"name": "user"}, {"name": "post", "migration": false}, {"name": "comment", "migration": true} ], "migrations": [ // Jeffrey Way's laracasts/generators needed to take care of this, otherwise the schema is ignored and it will generate simple migrations files {"users_infos": "username:string, email:string:unique"}, {"posts": "id:integer:unique, title:string"}, {"comments": "id:integer:unique, post_id:integer:unique, text:string"} ], "views": ["home", "dashboard", "pages.users", "pages.posts", "pages.comments"], "assets": [ {"sass": ["file1.sass", "file2.sass", "partials/subfile1.sass"]}, {"js": ["file1.js", "file2.js", "plugins/file1.js", "plugins/file2.js"]} ], "publics": ["folder1", "folder2", "folder2/subfolder1", "folder2/subfolder2"] }
运行命令
在 json 文件中生成所有内容(在 Laravel 应用程序的根目录中为 AppSkeleton.json)
$ php artisan make:appskeleton
您可以指定您的 json 文件路径
$ php artisan make:appskeleton path/to/your/appskeleton_file.json
仅生成控制器和视图
$ php artisan make:appskeleton --controllers --views
备份生成的文件
$ php artisan make:appskeleton [--controllers] [--views] --backup
删除生成的文件
$ php artisan make:appskeleton [--controllers] [--views] --clear
强制删除生成的文件和目录,包括备份
$ php artisan make:appskeleton [--controllers] [--views] --clear --f
可用参数
path/to/file.json set the json file that contains the structure of the app
可用选项
--routes parse routes
--controllers parse controllers
--models parse models
--migrations parse migrations
--views parse views
--assets parse assets
--publics parse publics
--routes parse routes
--b, --backup make backup of generated files
--c, --clear delete generated files
--f, --force force delete generated files even backups