ignasbernotas/laravel-model-generator
最新稳定版本:1.2.3
Composer 安装命令:
composer require ignasbernotas/laravel-model-generator
包简介
Laravel 5 model generator from existing schema
关键字:
README 文档
README
I'm very sorry to announce that I no longer have time to maintain this package. This project was originally created over a couple of days when I needed to migrate an existing project onto Laravel. Even though it's being actively used (over 50k installs!), I can't find the time to keep track of the PRs and what changes might break things in new/old Laravel versions, nor have I had the need to use it after the initial release. The codebase is a mess and it desperately cries for a rewrite.
Please use reliese/laravel package instead.
Model Generator
Laravel 5 model generator for an existing schema.
It plugs into your existing database and generates model class files based on the existing tables.
Installation
composer require ignasbernotas/laravel-model-generator --dev
You'll only want to use these generators for local development, so you don't want to update the production providers array in config/app.php. Instead, add the provider in app/Providers/AppServiceProvider.php, like so:
<?php public function register() { if ($this->app->environment() == 'local') { $this->app->register('Iber\Generator\ModelGeneratorProvider'); } }
Help & Options
php artisan help make:models Usage: make:models [options] Options: --tables[=TABLES] Comma separated table names to generate --prefix[=PREFIX] Table Prefix [default: DB::getTablePrefix()] --dir[=DIR] Model directory [default: "Models/"] --extends[=EXTENDS] Parent class [default: "Illuminate\Database\Eloquent\Model"] --fillable[=FILLABLE] Rules for $fillable array columns [default: ""] --guarded[=GUARDED] Rules for $guarded array columns [default: "ends:_guarded"] --timestamps[=TIMESTAMPS] Rules for $timestamps columns [default: "ends:_at"] -i, --ignore[=IGNORE] Ignores the tables you define, separated with , -f, --force[=FORCE] Force override [default: false] -s, --ignoresystem If you want to ignore system tables. Just type --ignoresystem or -s -m, --getset Defines if you want to generate set and get methods -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: Build models from existing schema.
Running the generator
php artisan make:models
Examples
Table users
SQL
CREATE TABLE `users` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `username` VARCHAR(64) NULL DEFAULT NULL, `password` VARCHAR(45) NULL DEFAULT NULL, `email` VARCHAR(45) NULL DEFAULT NULL, `name` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB;
Generated Models/Users.php class
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Users extends Model { public $timestamps = false; protected $table = 'users'; protected $fillable = ['username', 'email', 'name']; protected $guarded = ['id', 'password']; }
Table posts
SQL
CREATE TABLE `posts` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(64) UNSIGNED NOT NULL DEFAULT '', `content` TEXT NOT NULL DEFAULT '', `created_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB;
Generated Models/Posts.php class
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Posts extends Model { public $timestamps = true; protected $table = 'posts'; protected $fillable = ['title', 'content', 'created_at', 'updated_at']; protected $guarded = ['id']; }
ignasbernotas/laravel-model-generator 适用场景与选型建议
ignasbernotas/laravel-model-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 206.42k 次下载、GitHub Stars 达 265, 最近一次更新时间为 2015 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「schema」 「model」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ignasbernotas/laravel-model-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ignasbernotas/laravel-model-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ignasbernotas/laravel-model-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Extension for Opis JSON Schema
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
EAV modeling package for Eloquent and Laravel.
serialize Symfony Forms into JSON schema
Interfaces for web resource models and services to retrieve and create them
统计信息
- 总下载量: 206.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 270
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-25