gianlu-api/laravel-design
Composer 安装命令:
composer require gianlu-api/laravel-design
包简介
Library to generate custom design structure in laravel
README 文档
README
Laravel Design is the library that allows you to quickly generate the architecture you desire.
Requirements
- PHP ^8.2
- Laravel > 11
Installation
composer require gianlu-api/laravel-design
Publish Resources
php artisan vendor:publish --tag=gianlu-api:laravel-design:config
It is not mandatory to publish the config; you can create your own and specify it when running the command.
Usage
First, you will need to fill out the configuration as explained below. Once the configuration file is ready, if you are using the laravel-design configuration file run:
php artisan design
Otherwise, if you are using your own configuration file:
php artisan design --config={your_config_name}
Configurations
it is possible to generate the following types of files:
- migrations =>
'migrations' - classes =>
'classes' - interfaces =>
'interfaces' - abstract classes =>
'abstract_classes' - models =>
'models' - controllers =>
'controllers'- options: type
- requests =>
'requests' - middlewares =>
'middlewares' - vue components =>
'vue_components'- options: type
- react components =>
'react_components' - blade components =>
'blade_views'
you can choose between these types of configuration, you can also mix them if you need
- name and path configuration
'key' => [
[
'name' =>'UserService',
'path' => '/Domains/User/Domain/Services',
]
]
'key' => [
'name' =>'UserService',
'path' => '/Domains/User/Domain/Services',
]
- path and names configuration
'key' => [
'path' => '/Domains/User/Domain/Services',
'names' => [
'UserRetrieverService',
'UserDataAccessService',
]
]
'key' => [
[
'path' => '/Domains/User/Domain/Services',
'names' => [
'UserRetrieverService',
'UserDataAccessService',
]
],
[
'path' => '/Domains/User/Domain/Dtos',
'names' => [
'CreateUserData',
'UpdateUserData',
]
]
]
- name configuration
'key' => [
'name' =>'/Domains/User/Domain/Services/UserService',
]
- mixed configuration example
'classes' => [
[
'name' =>'UserType',
'path' => '/Domains/User/Domain/Enums',
],
[
'path' => '/Domains/User/Domain/Services',
'names' => [
'UserRetrieverService',
'UserDataAccessService',
]
],
[
'path' => '/Domains/User/Domain/Dtos',
'names' => [
'CreateUserData',
'UpdateUserData',
]
]
'name' =>'/Domains/User/Domain/Repositories/UserRepository',
]
Migrations configruration
'migrations' => [
'table' => 'test_domain',
]
'migrations' => [
'tables' => ['test_domain', 'test_domain_2']
]
Controllers configruration
it is possible for controllers to choose whether api or resource methods should be created as allowed by Laravel, by adding to the configuration array 'type' => api for api or type => resource for resources
Vue Components Configuration
it is possible for vue components to choose options between composition_api 'type' => 'compositions' and 'type' => 'options', by default a compositions component is created
Name Passed by Command
If you want, you can also pass the domain name directly to the command, so you never have to change your config structure once it’s defined like this.
[
"migrations" => [
"table" => "&"
],
'models' => [
'name' => '/Domains/&/Domain/Models/&',
],
"classes" => [
[
"path" =>"/Domains/&/Domain/Services",
"names" => ["&RetrieverService", "&DataAccessService"]
],
[
"path" =>"/Domains/&/Domain/Repositories",
"name" => "&Repository",
]
],
"interfaces" => [
"path" =>"/Domains//&/DOmain/Interfaces",
"names" => ["&ServiceRetrieverInterface", "&DataAccessServiceInterface", "&RepositoryInterface"]
],
"abstract_classes" => [
[
"path" =>"/Domains/&/Domain/Abstracts",
"name" => "&Abstract",
]
],
"requests" => [
"name" =>"../../App/Http/&/Requests/&Request",
],
"middlewares" => [
"name" =>"../../App/Http/&/Middlewares/&Middleware",
],
"resources" => [
"name" =>"../../App/Http/&/Resources/&Resource",
],
"controllers" => [
"name" =>"../../App/Http/&/Controllers/&Controller",
],
];
Now you can run the command like this
php artisan design {name}
Configuration Example
First, you will need to fill out the configuration file as follows.
[
"migrations" => [
"table" => "users"
],
'models' => [
'name' => '/Domains/User/Domain/Models/User',
],
"classes" => [
[
"path" =>"/Domains/User/Domain/Services",
"names" => ["UserRetrieverService", "UserDataAccessService"]
],
[
"path" =>"/Domains/User/Domain/Repositories",
"name" => "UserRepository",
]
],
"interfaces" => [
"path" =>"/Domains/User/Domain/Interfaces",
"names" => ["UserServiceRetrieverInterface", "UserDataAccessServiceInterface", "UserRepositoryInterface"]
],
"abstract_classes" => [
[
"path" =>"/Domains/User/Domain/Abstracts",
"name" => "UserAbstract",
]
],
"requests" => [
"name" =>"../../App/Http/User/Requests/UserRequest",
],
"middlewares" => [
"name" =>"../../App/Http/User/Middlewares/UserMiddleware",
],
"resources" => [
"name" =>"../../App/Http/User/Resources/UserResource",
],
"controllers" => [
"name" =>"../../App/Http/User/Controllers/UserController",
],
"blade_views" => [
"name" => "UserPage",
],
"vue_components" => [
"name" => "UserPage",
"path" => "js/Pages",
],
"react_components" => [
"name" => "UserPage",
"path" => "js/Pages",
]
];
If you want to create only specific components, simply leave the unwanted arrays empty. For example, if you need to create only a migration, model, service, and repository.
[
"migrations" => [
"table" => "users"
],
'models' => [
'name' => '/Domains/User/Domain/Models/User',
],
"classes" => [
[
"path" =>"/Domains/User/Domain/Services",
"names" => ["UserRetrieverService", "UserDataAccessService"]
],
[
"path" =>"/Domains/User/Domain/Repositories",
"name" => "UserRepository",
]
],
"interfaces" => [],
"abstract_classes" => [],
"requests" => [],
"middlewares" => [],
"resources" => [],
"controllers" => [],
"blade_views" => [],
"vue_components" => [],
"react_components" => []
];
Laravel Commands
Add ../../ before the path where you want to create the class; otherwise, the class will be created following Laravel's default path. For example, for the Controller: name => ../../App/Http/User/Controllers/UserController, the Controller will be created in app/App/Http/User/Controllers/UserController. On the other hand, if we use name => UserController, it will be created in app/Http/Controllers/UserController.
Other Commands
php artisan design:class {class_name} {class_path}
php artisan design:interface {interface_name} {interface_path}
php artisan design:class:abstract {abstarct_class_name} {abstract_class_path}
php artisan design:view:vue {vue_component_name} {vue_component_path} {--type=options || compositions}
Default type for Vue components is composition api.
php artisan design:view:react {react_component_name} {react_component_path}
gianlu-api/laravel-design 适用场景与选型建议
gianlu-api/laravel-design 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 213 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gianlu-api/laravel-design 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gianlu-api/laravel-design 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gianlu-api/laravel-design 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 213
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-26