chipaau/support

基于 Laravel 框架,集成 jsonapi 支持库,并扩展了验证支持

1.0.3 2017-05-24 08:06 UTC

README

此包包含一系列开箱即用的生成器

  • support:resource
  • support:resource:controller
  • support:resource:model
  • support:resource:repository
  • support:resource:request
  • support:resource:route
  • support:resource:schema
  • support:resource:validator

更多功能正在路上

使用方法

步骤 1:通过 Composer 安装

composer require chipaau/support --dev

步骤 2:添加服务提供者

您只想在本地开发中使用这些生成器,所以您不想更新生产环境的 providers 数组在 config/app.php 中。相反,在 app/Providers/AppServiceProvider.php 中添加提供者,如下所示

public function register()
{
	if ($this->app->environment() == 'local') {
		$this->app->register(\Support\SupportServiceProvider::class);
	}
}

步骤 3:运行 Artisan 命令!

您已设置完毕。在控制台运行 php artisan,您将在 support:* 命名空间部分看到新命令。

示例

创建完整的资源包

php artisan support:resource ResourceOne ResourceTwo ResourceThree ...

请注意我们使用的格式,当给定的命令需要创建多个资源时,我们用空格将它们分开

这将创建支持模块正常工作的所需完整包。此包包括

  • 资源控制器
  • 资源模型
  • 资源仓库
  • 资源请求
  • 将资源路由添加到路由文件中
  • 资源模式
  • 资源验证器

创建资源单独的元素

php artisan support:resource:controller ResourceOne ResourceTwo ResourceThree ...

这将创建所需资源的控制器。这可以与其他所有可用的 artisan 命令一起使用。

为模块生成资源

php artisan vendor:publish --tag="support"

这将复制模块文件生成所需配置文件到 config 目录。

php artisan support:resource ResourceOne ResourceTwo ResourceThree ... --module="ModuleName"

这将创建支持模块所需完整包,位于 config/support.php 配置文件中包含的模块文件夹内。这可以与其他所有可用的 artisan 命令一起使用。