skagarwal/generators 问题修复 & 功能扩展

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

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

skagarwal/generators

最新稳定版本:1.0.5

Composer 安装命令:

composer require skagarwal/generators

包简介

Directory Structure Laravel 5.1 Generator.

README 文档

README

Laravel-5.1-Generators

Build Status Latest Stable Version Latest Unstable Version License

If you like to keep your laravel appliaction in well formed structure and tired of making all the directories and subdirectories manually for every model, Then this package will help you automate this process.

This Package Strictly Follows The Directory Structure:

app/
  |
  |_Foo/
    |
    |_Foo.php // The Eloquent Model
    |
    |_Contracts/
      |
      |_FooRepository.php // black interface
    |
    |_Events/
    |
    |_Jobs/
    |
    |_Listeners/
    |
    |_Repositories/
      |
      |_EloquentFooRepository.php // impletements the FooRepository.php interface out of the box.

**Avaiabale Commands:** - `create:model` - `create:repository` - `create:event` - `create:listener` - `create:job`

Few More to Come

Usage

Step 1: Install Through Composer

composer require skagarwal/generators --dev

Step 2: Add the Service Provider

Add the SKAgarwal\Generators\GeneratorsServiceProvider to the Config/app.php's providers array

Config/app.php

'providers' => [
  ...
  ...
  ...
  
  'SKAgarwal\Generators\GeneratorsServiceProvider',
],

Step 3: Run Artisan!

You're all set. Run php artisan from the console, and you'll see the new commands in the make:* namespace section.

# Commands

create:model

Description:

  • Creates a model, migration and the directory structure.

Arguments:

  • model - Required. Name of the model to be created.

Options:

  • --migration - Optional. If provided, Migration for the Model will be created.

usage:

php artisan create:model Foo ---migration

This will produce the Following:

app/
  |
  |_Foo/
    |
    |_Foo.php // The Eloquent Model
    |
    |_Contracts/
      |
      |_FooRepository.php // black interface
    |
    |_Events/
    |
    |_Policies/
    |
    |_Jobs/
    |
    |_Listeners/
    |
    |_Repositories/
      |
      |_EloquentFooRepository.php // impletements the FooRepository.php interface out of the box.

And since --migration option is provided, there will be a migration for Foo in Database\Migrations\.

create:repository

Description:

  • Creates a repository interface and its eloquent implimentation in respective directories.

Arguments:

  • model - Required. The Model Name. Repository Will Be Created Under This Model Directory.

Options:

  • --repository - Optional. The Repository Name to be created. If not provided, Repository with the Model Name will be created.

Usage:

php artisan create:repository Foo

This will produce:

app\Foo\Contracts\FooRepository.php
app\Foo\Repositories\EloquentFooRepository.php

If --repository=Bar or -r Bar is provided, then it will produce:

app\Foo\Contracts\BarRepository.php
app\Foo\Repositories\EloquentBarRepository.php

Note:

  • Do not forget to bind the interface to its implimentation in Service container.

create:event

Description:

  • Creates a event class in {model}/Events/ directory.

Arguments:

  • name - Required. Name of the event class.

Options:

  • model - Required. Name of the model the event belongs to.

Usage:

php artisan create:event UserRegistered --model=User

This will produce:

User\Events\UserRegistered.php

create:listener

Description:

  • Creates a event listener in {model}\Listeners\ directory.

Arguments:

  • name - Required. Name of the event listener.

Options:

  • model - Required. Name of the model lsitener belongs to.
  • event - Required. Name fo the event listener is being listened for.
  • queued - Optional Indicated listener should be queued.

Usage:

php artisan create:listener SendWelcomeEmail --event=UserRegistered --model=User

This will produce:

User\Listeners\SendWelcomeEmail.php

Note:

  • Do not forget to register the listener for the event in EventServiceProvider.

create:job

Description:

  • Creates a job in {model}\Jobs\ directory.

Arguments:

  • name - Required. Name of the job.

Options:

  • model - Required. Name of the model job belongs to.
  • queued - Optional Indicated listener should be queued.

Usage:

php artisan create:job RegisterUser --model=User --queued

This will produce:

User\Jobs\RegisterUser.php

create:policy

Description:

  • Creates a policy in {model}\Policies\ directory.

Arguments:

  • name - Required. Name of the policy.

Options:

  • model - Required. Name of the model policy belongs to.

Usage:

php artisan create:policy PostPolicy --model=Post

This will produce:

Post\Policies\PostPolicy.php

skagarwal/generators 适用场景与选型建议

skagarwal/generators 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 228 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「generators」 「Laravel 5.1」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 skagarwal/generators 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-28