tinymeng/laravel-generation-model
Composer 安装命令:
composer require tinymeng/laravel-generation-model
包简介
tinymeng Components for Laravel Framework code generation.
README 文档
README
tinymeng Laravel Model Generator aims to speed up the development process of Laravel applications by providing some convenient code-generation capabilities. The tool inspects your database structure, including column names and foreign keys, in order to automatically generate Models that have correctly typed properties, along with any relationships to other Models.
How does it work?
This package expects that you are using laravel-generation-model 5.1 or above.
You will need to import the tinymeng/laravel-generation-model package via composer:
Configuration
It is recommended that this package should only be used on a local environment for security reasons. You should install it via composer using the --dev option like this:
composer require tinymeng/laravel-generation-model --dev
Add the models.php configuration file to your config directory and clear the config cache:
php artisan vendor:publish --tag=tinymeng-models
# Let's refresh our config cache just in case
php artisan config:clear
Models
Usage
Assuming you have already configured your database, you are now all set to go.
- Let's scaffold some of your models from your default connection.
php artisan code:models
- You can scaffold a specific table like this:
php artisan code:models --table=users
- You can also specify the connection:
php artisan code:models --connection=mysql
- If you are using a MySQL database, you can specify which schema you want to scaffold:
php artisan code:models --schema=shop
Customizing Model Scaffolding
To change the scaffolding behaviour you can make config/models.php configuration file
fit your database needs. Check it out ;-)
Tips
1. Keeping model changes
You may want to generate your models as often as you change your database. In order
not to lose your own model changes, you should set base_files to true in your config/models.php.
When you enable this feature your models will inherit their base configurations from base models. You should avoid adding code to your base models, since you will lose all changes when they are generated again.
Note: You will end up with two models for the same table and you may think it is a horrible idea to have two classes for the same thing. However, it is up to you to decide whether this approach gives value to your project :-)
Support
For the time being, this package supports MySQL, PostgreSQL and SQLite databases. Support for other databases are encouraged to be added through pull requests.
tinymeng/laravel-generation-model 适用场景与选型建议
tinymeng/laravel-generation-model 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「tinymeng」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tinymeng/laravel-generation-model 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tinymeng/laravel-generation-model 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tinymeng/laravel-generation-model 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
yii2 use solr
wechat sina qq alipay twitter google line facebook oauth
php发送邮件email
Alfabank REST API integration
Easy to use workerman's websocket
a Open Source PHP Code Confusion + Encryption Project
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-04