bluecode/laravel-generator

dev-master 2017-09-16 02:05 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:21:33 UTC


README

Codacy Badge Latest Stable Version Total Downloads Latest Unstable Version License

此包扩展了 Laravel 命令,以便使用自定义模板。此外,添加了一些新的命令,如生成 MVC、创建新包。

文档正在制作中...

文档

  1. 安装
  2. 发布
  3. 生成命令
  4. 选项

安装

  1. 将此包添加到您的 composer.json 文件中
composer require bluecode/laravel-generator
  1. 运行 composer update
composer update
  1. 将 ServiceProviders 添加到 config/app.php 文件中的 providers 数组中
Bluecode\Generator\GeneratorServiceProvider::class,

因为我们使用 laravelcollective/html 作为依赖项
因此需要添加那些 ServiceProviders。

Collective\Html\HtmlServiceProvider::class,

为了方便,将这些 facade 添加到 config/app.php 文件中的别名数组中

'Form'      => Collective\Html\FormFacade::class,
'Html'      => Collective\Html\HtmlFacade::class,

发布

  1. 发布配置文件 generator.php
php artisan vendor:publish --tag=laravel-generator.config
  1. 将模板文件夹发布到 resources/vendor/laravel-generator/templates
php artisan vendor:publish --tag=laravel-generator.template

生成命令

  1. 生成迁移
php artisan gen:migrate MigrationName

例如:

php artisan gen:migrate create_posts_table
  1. 生成模型

php artisan gen:model ModelName

例如:

php artisan gen:model Post
  1. 生成控制器
php artisan gen:model ModelName

例如:

php artisan gen:model Post
  1. 生成视图
php artisan gen:view ViewName

例如:

php artisan gen:view index
php artisan gen:view create
  1. 生成 MVC
php artisan gen:mvc ModelName

例如:

php artisan gen:mvc Post
php artisan gen:mvc Post --actions=index,create,edit
  1. 生成包
  php artisan gen:package VendorName PackageName

例如:

php artisan gen:package Module Post
php artisan gen:package Module Post --path=packages/post
php artisan gen:package Module Post --actions=index,create,edit

选项

使用 --overwrite 以覆盖所有命令上的现有文件。

致谢

此 Laravel 生成器由 Bluecode 创建。

欢迎报告错误和分支 :)