hamzaouaghad/multilayering
Composer 安装命令:
composer require hamzaouaghad/multilayering
包简介
A tiny laravel package to speed up the workflow with the multilayering convetion
README 文档
README
This package is a tiny laravel package that generates artisan commands to generate the multilayer conventions faster, and speed up the workflow.
If you don't know what multilayer is , feel free to have quick read at coderwall
Install
Via Composer
$ composer require hamzaouaghad/multilayering
Usage
Make sure you add this line in your Config\app.php
'providers' => [ Hamzaouaghad\Multilayering\MultilayerGeneratorServiceProvider::class, Hamzaouaghad\Multilayering\RegisterCommandsServiceProvider::class, ],
save and run
$ composer dumpautoload -o $ php artisan vendor:publish
Now to go your 'app/providers/', you will find a new providers added :
MultilayerGeneratorServiceProvider
If it's your first time, and you still need to generate the new folder structure, please run:
php artisan make:multilayer
And afterwards, again, add this to your providers:
App\Providers\MultilayerGeneratorServiceProvider`.
Again,
$ composer dumpautoload -o $ php artisan vendor:publish
I could easily automate the process of adding all of these service providers and calling them for you, however, this is never the best approach, if not a bad practice, as adding them manually -unlinke automatic registering- actually keeps track of all of the service providers you are using, in your providers array.
So bare the pain of keeping your work organized, it's worth it.
If you wish to quicken the paste, and bake all, you may use the following command :
php artisan bake:all ClassName
This command will generate an eloquent class, an interface for it, and a repository that uses this interface. Also, at the http layer, it generates a motor for it that injects that repository.
If you may to bake all with specifics, you may use the following options:
--interface : The name of the interface to be created for our calss --motor : the name of the motor to be created for our class --trait : the name of the trait that your motor maye use --repository : the name of the repository that this class would be covered under.
After each file generation, you'll have to run
$ php artisan vendor:publish
As it will mention to you everytime, so I think you won't forget.
##Examples
php artisan bake:all User --repository=Accounts --interface=Security --motor=STAFF --trait=Authentication
This will create :
class User extends Eloquent
and
interface SecurityInterface
and
class AccountsRepository implements SecurityInterface
and
class STAFFmotor extends Motor { public function __construct(AccountsRepository $repo) { $this->repository = $repo; } use /Authentication; }
After all of this, the Providers\MultilayerGeneratorServiceProvider will be updated as follows :
class MultilayerGeneratorServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { // } /** * Register the application services. * * @return void */ public function register() { $this->app->booting(function(){ $loader = \Illuminate\Foundation\AliasLoader::getInstance(); /* | | Repositories Classes | */ $loader->alias('AccountsRepository', 'App\DataLayer\Repositories\AccountsRepository'); $loader->alias('AccountsRepoInterface', 'AccountsRepository'); /* | | Object Classes | */ $loader->alias('User', 'App\DataLayer\Objects\User'); /* | | Traits | */ $loader->alias('CRUDtrait', 'App\Http\Traits\CRUDtrait');//don't modify this. $loader->alias('AuthenticationTrait', 'App\Http\Traits\AuthenticationTrait'); /* | | Motors | */ $loader->alias('Motor', 'App\Http\Motors\Motor'); $loader->alias('STAFFmotor', 'App\Http\Controllers\Motors\STAFFmotor'); }); } }
Available commands
bake bake:all Creates an eloquent class, an interface and a repository for it, also a motor, and a trait if specified. bake:datalayer Bake the data layer for the given class make make:controller Create a new resource controller class make:datalayer Creates the datalayer directory structure make:datalayer:class Creates an eloquent class, its interface and its repository. make:datalayer:interface Creates an interface. make:datalayer:repository Creates a repository make:httplayer Creates the httplayer directory structure make:httplayer:basemotor Creates an abstract motor class for inheritence. make:httplayer:motor Creates a motor, with the injected specified repository, and the trait to be used. make:httplayer:trait make:multilayer This command generates the directory structure for the multilayering conventions.
If you wish to go your own way, without mass baking, you can use the following
php artisan make:datalayer:class <name> php artisan make:datalayer:interface <name> php artisan make:datalayer:repository <name> (with options: --interface= the one you wish your repo to implement, --class=The class whose repo is this php artisan make:httplayer:motor <name> --trait= : The trait that is desired to be used --repository= : A specific repository to be implemented php artisan make:httplayer:trait <name>
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email ouaghad.hamza@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
hamzaouaghad/multilayering 适用场景与选型建议
hamzaouaghad/multilayering 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Layers」 「HamzaOuaghad」 「multilayering」 「seperation-of-concerns」 「soc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hamzaouaghad/multilayering 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hamzaouaghad/multilayering 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hamzaouaghad/multilayering 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Object-oriented image handling and manipulation library
This package creates a layer structure to organize your laravel projects
Lara-Driven is a package designed to create and organize layers using the Domain Drive Design methodology.
Alfabank REST API integration
A tiny laravel package that runs artisan commands in production, specifically made for people who do not necessarily have access to SSH and still need to run migrations for instance.
Laravel package for Accurate Online API integration.
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-11