notiv/laravel-domain-commands 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

notiv/laravel-domain-commands

Composer 安装命令:

composer require notiv/laravel-domain-commands

包简介

Artisan commands to Laravel apps that utilizes Domain Driven Design.

README 文档

README

Installation

composer require notiv/laravel-domain-commands

Add CommandLoader::loadCommands() to app/Console/Kernel.php

<?php

...
+use Notiv\Console\CommandLoader;

class Kernel extends ConsoleKernel
{
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

+       CommandLoader::loadCommands();

        require base_path('routes/console.php');
    }
}

Not a good solution, but i don't know how else I can register commands after everything

Add "Domain\\": "app/Domain/" to composer.json

"autoload": {
  "psr-4": {
      "App\\": "app/",
+     "Domain\\": "app/Domain/",
      "Database\\Factories\\": "database/factories/",
      "Database\\Seeders\\": "database/seeders/"
  }
},

You can publish config, if you want

php artisan vendor:publish --tag="domain-commands-config"

Domain Commands

  • make:model <domain:model>

    Create a new Eloquent model class

    Example: php artisan make:model User:User

    Options:

    • --force Create the class even if the model already exists
    • -a, --all Generate a migration, seeder & factory for the model
    • -f, --factory Create a new factory for the model
    • -m, --migration Create a new migration file for the model
    • -s, --seed Create a new seeder file for the model
    • -p, --pivot Indicates if the generated model should be a custom intermediate table model
  • make:action <domain:action>

    Create an action for a given domain

    Example: php artisan make:action User:CreateUserAction

  • make:dto <domain:dto>

    Create a dto for a given domain

    Example: php artisan make:dto User:CreateUserDTO

    You should install https://github.com/spatie/data-transfer-object for convenience

    Options:

    • -r, --request DTO file with static fromRequest method
  • make:cast <domain:cast>

    Create a new custom Eloquent cast class

    Example: php artisan make:cast User:JsonCast

  • make:collection <domain:collection>

    Create a collection for a given domain

    Example: php artisan make:collection User:UserCollection

  • make:event <domain:event>

    Create a new event class

    Example: php artisan make:event User:UserCreatedEvent

  • make:enum <domain:enum>

    Create an enum for a given domain

    Example: php artisan make:enum User:UserColorEnum

  • make:listener <domain:listener>

    Create a new event listener class

    Example: php artisan make:listener User:SendSlackMessage -e User:UserCreatedEvent --queued

    Options:

    • --queued Indicates the event listener should be queued
    • -e, --event=<domain:event> The event class being listened for
  • make:observer <domain:observer>

    Create a new observer class

    Example: php artisan make:observer User:UserObserver -m User:User

    Options:

    • -m, --model=<domain:model> The model that the observer applies to
  • make:policy <domain:policy>

    Create a new policy class

    Example: php artisan make:policy User:UserPolicy -m User:Post

    Options:

    • -m, --model=<domain:model> The model that the policy applies to
    • -g, --guard=<domain:model> The guard that the policy relies on
  • make:query-builder <domain:query-builder>

    Create a query builder for a given domain

    Example: php artisan make:query-builder User:UserQueryBuilder

  • make:rule <domain:rule>

    Create a new validation rule

    Example: php artisan make:rule User:PasswordMinlengthRule

    Options:

    • -i, --implicit Generate an implicit rule

Application Commands

  • make:controller <domain:controller>

    Create a new controller class

    Example: php artisan make:controller User:UserController

    Options:

    • --force Create the class even if the controller already exists
    • --api Exclude the create and edit methods from the controller
    • -i, --invokable Generate a single method, invokable controller class
    • -m <domain:model>, --model=<domain:model> Generate a resource controller for the given model
    • -p <domain:model>, --parent=<domain:model> Generate a nested resource controller class
    • -r, --resource Generate a resource controller class
  • make:request <domain:request>

    Create a new form request class

    Example: php artisan make:request User:LoginRequest

  • make:job <domain:job>

    Create a new job class

    Example: php artisan make:job User:SendMessageJob

    Options:

    • --sync Indicates that job should be synchronous
  • make:mail <domain:mail>

    Create a new email class

    Example: php artisan make:mail User:WelcomeUser

    Options:

    • -f, --force Create the class even if the mailable already exists
    • -m, --markdown[=MARKDOWN] Create a new Markdown template for the mailable
  • make:notification <domain:notification>

    Create a new notification class

    Example: php artisan make:notification User:InvoicePaid

    Options:

    • -f, --force Create the class even if the notification already exists
    • -m, --markdown[=MARKDOWN] Create a new Markdown template for the notification
  • make:middleware <domain:middleware>

    Create a new middleware class

    Example: php artisan make:middleware User:AuthMiddleware

  • make:resource <domain:resource>

    Create a new resource class

    Example: php artisan make:resource User:UserResource

    Options:

    • -c, --collection Create a resource collection
  • make:component <domain:component>

    Create a new view component class

    Example: php artisan make:component User:UserComponent

    Options:

    • --force Create the class even if the component already exists
    • --inline Create a component that renders an inline view
  • make:view-model <domain:view-model>

    Create a view-model for a given app

    Example: php artisan make:view-model User:UsersViewModel

Database Commands

  • make:factory <domain:factory>

    Create a new model factory

    Example: php artisan make:factory UserFactory

    Options:

    • -m <domain:model>, --model=<domain:model> Bind factory to the model

TODO:

Thanks

notiv/laravel-domain-commands 适用场景与选型建议

notiv/laravel-domain-commands 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 notiv/laravel-domain-commands 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 notiv/laravel-domain-commands 我们能提供哪些服务?
定制开发 / 二次开发

基于 notiv/laravel-domain-commands 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 60
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-04