dev-lnk/laravel-code-builder
Composer 安装命令:
composer require dev-lnk/laravel-code-builder
包简介
Generate classes and files from table schema
关键字:
README 文档
README
Description
Hello Laravel users! This package allows you to generate code from the schema of your SQL table. The following entities will be generated:
These examples have been generated from a table created by migration:
Schema::create('products', function (Blueprint $table) { $table->id(); $table->string('title')->default('Default'); $table->text('content'); $table->foreignIdFor(User::class) ->nullable() ->constrained() ->nullOnDelete() ->cascadeOnUpdate(); $table->smallInteger('sort_number')->default(0); $table->boolean('is_active')->default(0); $table->timestamps(); $table->softDeletes(); });
What is this package for?
This package allows you to significantly reduce the routine while coding and focus on developing.
Installation
composer require dev-lnk/laravel-code-builder --dev
Configuration:
Publish the package configuration file:
php artisan vendor:publish --tag=laravel-code-builder
Usage
The basic command signature looks like this:
code:build {entity} {table?}
Let's say we want to create classes for the base table users based on the User entity. To do this you need to run the following command:
php artisan code:build User
You will be presented with a list of your tables, choose which table you want to generate the code based on:
┌ Table ───────────────────────────────────────────────────────┐ │ ○ migrations │ │ │ ○ password_reset_tokens │ │ │ ○ products │ │ │ ○ sessions │ │ │ › ● users ┃ │ └──────────────────────────────────────────────────────────────┘
You can also specify part of the table name to shorten the list
php artisan code:build User us ┌ Table ───────────────────────────────────────────────────────┐ │ › ● users │ └──────────────────────────────────────────────────────────────┘
If you have not specified a generation_path in the configuration file, you will be offered 2 options:
┌ Where to generate the result? ───────────────────────────────┐ │ › ● In the project directories │ │ ○ To the generation folder: `app/Generation` │ └──────────────────────────────────────────────────────────────┘
The first option will create all files according to the folders in your app_path directory. If a file with the same name is found, you will be prompted to replace it:
app/Models/User.php was created successfully! ... ┌ Controller already exists, are you sure you want to replace it? ┐ │ Yes │ └─────────────────────────────────────────────────────────────────┘ app/Http/Controllers/UserController.php was created successfully! ...
In the second option, all files will be generated in the app/Generation folder
app/Generation/Models/User.php was created successfully!
...
In the builders configuration you can comment out those builders that you do not want to be executed
return [ 'builders' => [ 'model', // 'addAction', // 'editAction', // 'request', // 'controller', // 'route', 'form', // 'DTO', // 'table', ], //... ];
You can generate certain entities using flags:
php artisan code:build user --model --request
Available options for the only flag:
--model--request--DTO--addAction--editAction--controller--route--form--table--typeScript--builder- Generates all builders specified in thebuildersconfiguration + your specified flag, for example:
php artisan code:build user --builders --request
Documentation
dev-lnk/laravel-code-builder 适用场景与选型建议
dev-lnk/laravel-code-builder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.75k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2024 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「schema」 「generation」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dev-lnk/laravel-code-builder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dev-lnk/laravel-code-builder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dev-lnk/laravel-code-builder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Toolset for generating PHP code
Extension for Opis JSON Schema
Fabricates patterns.
EAV modeling package for Eloquent and Laravel.
serialize Symfony Forms into JSON schema
PHP PDF library for generating and importing PDF documents. A component of the Pop PHP Framework
统计信息
- 总下载量: 4.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-30