ikechukwukalu / magicmake
一个针对有观点的Laravel编码风格的脚手架包。
v1.0.0
2024-02-26 21:43 UTC
Requires
- php: >=7.3
- beyondcode/laravel-websockets: ^1.14
- calebporzio/sushi: ^2.4
- doctrine/dbal: ^3.5
- hisorange/browser-detect: ^4.5
- ikechukwukalu/clamavfileupload: ^2.0
- ikechukwukalu/makeservice: ^1.0
- ikechukwukalu/requirepin: ^1.0
- illuminate/console: ^8.0|^9.0|^10.0
- illuminate/support: ^8.0|^9.0|^10.0
- knuckleswtf/scribe: ^4.29
- kreait/laravel-firebase: ^5.6
- laragear/two-factor: ^1.2
- laravel/socialite: ^5.5
- laravel/ui: ^4.4
- mobiledetect/mobiledetectlib: 2.8.32
- predis/predis: ^2.1
- pusher/pusher-php-server: ^7.2
- react/http: 1.9.0
- sentry/sentry-laravel: ^4.1
- spatie/laravel-activitylog: ^4.7
- spatie/laravel-permission: ^6.3
- stevebauman/location: ^6.6
- symfony/console: ^5.4|^6.0
- symfony/finder: ^6.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0
- php-parallel-lint/php-parallel-lint: dev-develop
- phpunit/phpunit: ^9.0|^10.0
This package is auto-updated.
Last update: 2024-09-01 20:30:32 UTC
README
一个针对有观点的Laravel编码风格的Laravel脚手架包。
要求
- PHP 7.3+
- Laravel 8+
安装步骤
composer require ikechukwukalu/magicmake
初始化类
为新的Laravel应用初始化准备好的类。
php artisan magic:init
这只有在 env('APP_ENV') === local
和 env(MAGIC_INIT_LOCK) === false
时才会运行。
基于模型的类
生成所有基于模型的准备类。
php artisan magic:model UserKyc
生成单个基于模型的准备类。
php artisan magic:contract UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:repository UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:service UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:controller UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:createRequest UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:updateRequest UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:deleteRequest UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:readRequest UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:api UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:test UserKyc --variable=userKyc --underscore=user_kyc php artisan magic:factory UserKyc --variable=userKyc --underscore=user_kyc
注意
将其添加到 config/api.php
。
'paginate' => [ ... 'user_kyc' => [ 'pageSize' => 10, ], ],
将其添加到 app/Providers/RepositoryServiceProvider.php
。
use App\Contracts\UserKycRepositoryInterface; use App\Repositories\UserKycRepository; public function register(): void { ... $this->app->bind(UserKycRepositoryInterface::class, UserKycRepository::class); }
完成设置
如果你已经运行了 php artisan magic:init
。
添加到 composer.json
文件。
"autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" }, "files": [ "app/Http/Helpers.php" ] },
之后运行
composer dump-autoload
添加到 config/app.php
。
/* * Package Service Providers... */ App\Providers\MacroServiceProvider::class, App\Providers\RepositoryServiceProvider::class,
添加到 app/Http/Kernel.php
中的 protected $middlewareAliases
protected $middlewareAliases = [ .... 'check.email.verification' => \App\Http\Middleware\CheckEmailVerification::class, ]
项目设置
php artisan ui bootstrap npm install composer install php artisan migrate --seed
运行开发服务器
npm run build
php artisan serve
php artisan test
注意
应用通知助手
$userNotificationData = new UserNotificationData($user->id, $title, $text); $user->notify(new DatabaseNotification($userNotificationData->toObject())); $emailData = new EmailData(subject: $title, lines: [$text], from: env('MAIL_FROM_ADDRESS'), remark: null, action: false, action_text: null, action_url: null, attachements: null); $user->notify(new EmailNotification($emailData->toObject())); $smsData = new SmsData($user->name, $text); $user->notify(new SmsNotification($smsData->toObject()));
许可证
MM包是在Apache 2.0许可证下授权的软件。