ammaraldwayma/laravel-maker
Composer 安装命令:
composer require ammaraldwayma/laravel-maker
包简介
Laravel Maker is a powerful Laravel package designed to elevate your development experience by introducing a set of custom Artisan commands. These commands are meticulously crafted to simplify and expedite the creation of essential components in your Laravel application, fostering a more efficient a
关键字:
README 文档
README
Laravel Maker is a powerful Laravel development package designed to help you to enhance your development process by creating Classes , Enums, Traits, Interfaces, Services and more with a single command.
With Laravel Maker you can create the following classes:
Installation
You can install the package via composer:
composer require ammaraldwayma/laravel-maker --dev
Usage
Creating a new Class
php artisan make:class Actions/StoreUserAction
This command will create a new class in the app/Actions directory. The class will be named StoreUserAction and will
contain the following code:
<?php namespace App\Actions; class StoreUserAction { }
Creating a new Enum
php artisan make:enum Statuses
This command will create a new enum class in the app/Enums directory. The class will be named Statuses and will
contain the following constants:
<?php namespace App\Enums; enum Statuses: string { // }
Creating a new Trait
php artisan make:trait HasStatus
This command will create a new trait class in the app/Traits directory. The class will be named HasStatus and will
contain the following code:
<?php namespace App\Traits; trait HasStatus { // }
Creating a new Interface
php artisan make:interface UserRepositoryInterface
This command will create a new interface class in the app/Interfaces directory. The class will be
named UserRepository and will contain the following code:
<?php namespace App\Interfaces; interface UserRepositoryInterface { // }
Creating a new Service / Third-party Service
php artisan make:service GoogleTranslationService
This command will create a new service class in the app/Services directory. The class will be
named GoogleTranslationService and will contain the following code:
<?php namespace App\Services; class GoogleTranslationService { /** * @param PendingRequest $httpClient * @param array $serviceKeys */ public function __construct( protected PendingRequest $httpClient, protected array $serviceKeys = [], ) { $this->serviceKeys = config('services.google_translation'); $this->httpClient = Http::asJson() ->acceptJson() ->withoutVerifying() ->baseUrl($this->serviceKeys['base_url']) ->timeout($this->serviceKeys['timeout']); } /** * Get {{ name }} data . * * @param array $data * @return array */ public function get(array $data = []): array { $response = $this->httpClient->get('/'); if ($response->failed()) { return [ 'status' => false, 'data' => [], ]; } return [ 'status' => true, 'data' => $response->json(), ]; } }
Creating a new Repository
php artisan make:repo UserRepository
This command will create a new repository class in the app/Repositories directory with a interface class in the
app/Repositories/Interfaces directory. The class will be named UserRepository and will contain the following code:
<?php namespace App\Repositories; use App\Repositories\Interfaces\UserRepositoryInterface; use App\Models\User; class UserRepository implements UserRepositoryInterface { /** * @param User $user */ public function __construct( protected User $user, ) { // } }
Customizing the default namespaces
You can customize the default namespaces for the different types of classes that you can generate it by the package by
- Publishing the config file:
php artisan vendor:publish --tag="maker-config"
- Changing the values of the
default_namespacesarray in the published config file:
return [ /* |-------------------------------------------------------------------------- | Default Namespaces |-------------------------------------------------------------------------- | Here you can specify the default namespaces for the different types of | classes that you can generate it by the package. | */ 'default_namespaces' => [ 'enum' => 'App\Enums', 'trait' => 'App\Traits', 'interface' => 'App\Interfaces', 'service' => 'App\Services', 'repository' => 'App\Repositories', ], ];
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
ammaraldwayma/laravel-maker 适用场景与选型建议
ammaraldwayma/laravel-maker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 836 次下载、GitHub Stars 达 25, 最近一次更新时间为 2023 年 12 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel maker」 「laravel-maker」 「Ammar Aldwayma」 「Laravel Development Tools」 「Laravel Development Commands」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ammaraldwayma/laravel-maker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ammaraldwayma/laravel-maker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ammaraldwayma/laravel-maker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Ownership simplify management of Eloquent model's owner.
:package_description
A user-definable table field type for Craft CMS
Laravel command line interface (CLI)
A simple way to create the files for my bundles and some other things
Extension of SymfonyMakerBundle
统计信息
- 总下载量: 836
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-27