cable8mm/xeed
Composer 安装命令:
composer create-project cable8mm/xeed
包简介
Xeed generates new model, seed, Nova resources, database seed, factory and migration files for Laravel & Nova based on data from the existing database table.
README 文档
README
Xeed generates new model, seed, Nova resources, database seed, factory and migration files for Laravel & Nova based on data from the existing database table.
Why Xeed?
Laravel already has migrations and factories, but:
- It cannot reverse-engineer existing databases
- It is repetitive for legacy projects
- Nova resources are manual and slow to maintain
Xeed solves this by generating everything from your real schema.
Tip
It can function as both php artisan xeed:* commands for Laravel & Nova providing 100% identical functionality. Therefore, you can use it within your own Laravel & Nova project.
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/xeed/ ❤️
Features
- Database testing is supported
- Generate models for Laravel
- Generate seed files for Laravel
- Generate Nova resources files for Laravel Nova
- Generate database seed files for Laravel
- Generate factories for Laravel
- Generate migrations for Laravel
- Generate belongsTo and hasMany relationships functions for Laravel
- Laravel multi & reserved columns supported
- Laravel integration
- MySQL, SQLite and PostgreSQL supported
Support & Tested
Preview
Installation
composer require cable8mm/xeed --dev
Usage
All commands use the current database connection to generate files automatically.
Global options:
-f Force overwrite existing files
Generators
Models:
# Generate all models from database in `app/Models` folder
php artisan xeed:model
php artisan xeed:model -f
Factories:
# Generate all factories from database in `database/factories' folder
php artisan xeed:factory
Seeders:
# Generate all seeds from database in `database/seeders` folder php artisan xeed:seeder # Generate all seeds from database in `database/seeders` folder php artisan xeed:faker-seeder
Migrations:
# Generate a database seed from database in `database/seeders` folder
php artisan xeed:database
Migrations:
# Generate all migrations from database in `database/migrations' folder
php artisan xeed:migration
Relations:
# Add the relation function to all models from database in `app/Models` folder
php artisan xeed:relation
Nova:
# Add the Laravel Nova resources to all tables in `app/Nova` folder
php artisan xeed:nova
Cleanup:
# Clean generated files, seeders, models, factories and migration files.
php artisan xeed:wipe
Formatting
# Modify all files to comply with the PSR-12. composer lint # Inspect all files to ensure compliance with PSR-12. composer inspect
Testing
Xeed uses an isolated SQLite database during tests, ensuring your real database is never affected.
# Run `vendor/bin/testbench package:test tests`
composer testpack
# Run `vendor/bin/phpunit tests` composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
The below can help you contribute.
The Xeed has a built-in SQLite database, allowing you to contribute easily without needing your own database. Simply create a new file for testing purposes and utilize it.
# Create a new empty file for SQLite database
touch database/database.sqlite
And then,
# Run tests composer test
Database seeds
For migrations and factories, when you need to execute tests for all database field types, utilize the following command.
# Import an 'xeeds' Table into the Database php artisan xeed # Drop the 'xeeds' Table from the Database php artisan xeed drop
Utilize migration files for all database field types by referring to the following location database/*.sql these files are saved in the specified folder.
Use testorchestral/testbench
You can utilize testorchestral/testbench to execute tests. When running Laravel commands, the generated files are saved in the vendor/orchestra/testbench-core/laravel/database folder.
Resources
Laravel columns description for mysql:
| Available Column Types | Field | Type | Null | Key | Default | Extra |
|---|---|---|---|---|---|---|
| id() | id | bigint unsigned | NO | PRI | auto_increment | |
| bigInteger('big_integer') | big_integer | bigint | NO | |||
| binary('binary') | binary | blob | NO | |||
| boolean('boolean') | boolean | tinyint(1) | NO | |||
| char('char', length: 100) | char | char(100) | NO | |||
| dateTimeTz('date_time_tz', precision: 0) | date_time_tz | datetime | NO | |||
| dateTime('date_time', precision: 0) | date_time | datetime | NO | |||
| date('date') | date | date | NO | |||
| decimal('decimal', total: 8, places: 2) | decimal | decimal(8,2) | NO | |||
| double('double') | double | double | NO | |||
| enum('enum', ['easy', 'hard']) | enum | enum('easy','hard') | NO | |||
| float('float', precision: 53) | float | double | NO | |||
| foreignId('foreign_id') | foreign_id | bigint unsigned | NO | |||
| foreignUlid('foreign_ulid') | foreign_ulid | char(26) | NO | |||
| foreignUuid('foreign_uuid') | foreign_uuid | char(36) | NO | |||
| geometry('geometry', subtype: 'point', srid: 0) | geometry | point | NO | |||
| integer('integer') | integer | int | NO | |||
| ipAddress('ip_address') | ip_address | varchar(45) | NO | |||
| json('json') | json | json | NO | |||
| jsonb('jsonb') | jsonb | json | NO | |||
| longText('long_text') | long_text | longtext | NO | |||
| macAddress('mac_address') | mac_address | varchar(17) | NO | |||
| mediumInteger('medium_integer') | medium_integer | mediumint | NO | |||
| mediumText('medium_text') | medium_text | mediumtext | NO | |||
| morphs('morph') | morph_type | varchar(255) | NO | MUL | ||
| Ditto make 2 fields | morph_id | bigint unsigned | NO | |||
| nullableTimestamps(precision: 0) | created_at | timestamp | YES | |||
| Ditto make 2 fields | updated_at | timestamp | YES | |||
| nullableMorphs('nullable_morph') | nullable_morph_type | varchar(255) | YES | MUL | ||
| Ditto make 2 fields | nullable_morph_id | bigint unsigned | YES | |||
| nullableUlidMorphs('nullable_ulid_morph') | nullable_ulid_morph_type | varchar(255) | YES | MUL | ||
| Ditto make 2 fields | nullable_ulid_morph_id | char(26) | YES | |||
| nullableUuidMorphs('nullable_uuid_morph') | nullable_uuid_morph_type | varchar(255) | YES | MUL | ||
| Ditto make 2 fields | nullable_uuid_morph_id | char(36) | YES | |||
| rememberToken() | remember_token | varchar(100) | YES | |||
| set('set', ['strawberry', 'vanilla']) | set | set('strawberry','vanilla') | NO | |||
| smallInteger('small_integer') | small_integer | smallint | NO | |||
| softDeletesTz('soft_delete_tz', precision: 0) | soft_delete_tz | timestamp | YES | |||
| softDeletes('soft_delete', precision: 0) | soft_delete | timestamp | YES | |||
| string('string', length: 100) | string | varchar(100) | NO | |||
| text('text') | text | text | NO | |||
| time('time_tz', 0) | time_tz | time | NO | |||
| time('time', 0) | time | time | NO | |||
| timestampTz('timestamp_tz', precision: 0) | timestamp_tz | timestamp | NO | |||
| timestamp('timestamp', precision: 0) | timestamp | timestamp | NO | |||
| tinyInteger('tiny_integer') | tiny_integer | tinyint | NO | |||
| tinyText('tiny_text') | tiny_text | tinytext | NO | |||
| unsignedBigInteger('unsigned_big_integer') | unsigned_big_integer | bigint unsigned | NO | |||
| unsignedInteger('unsigned_integer') | unsigned_integer | int unsigned | NO | |||
| unsignedMediumInteger('unsigned_medium_integer') | unsigned_medium_integer | mediumint unsigned | NO | |||
| unsignedSmallInteger('unsigned_small_integer') | unsigned_small_integer | smallint unsigned | NO | |||
| unsignedTinyInteger('unsigned_tiny_integer') | unsigned_tiny_integer | tinyint unsigned | NO | |||
| ulidMorphs('ulid_morph') | ulid_morph_type | varchar(255) | NO | MUL | ||
| Ditto make 2 fields | ulid_morph_id | char(26) | NO | |||
| uuidMorphs('uuid_morph') | uuid_morph_type | varchar(255) | NO | MUL | ||
| Ditto make 2 fields | uuid_morph_id | char(36) | NO | |||
| ulid('ulid') | ulid | char(26) | NO | |||
| uuid('uuid') | uuid | char(36) | NO | |||
| year('year') | year | year | NO |
Code of Conduct
In order to ensure that the community is welcoming to all, please review and abide by the CODE OF CONDUCT.
Credits
License
The Xeed project is open-sourced software licensed under the MIT license.
cable8mm/xeed 适用场景与选型建议
cable8mm/xeed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 87, 最近一次更新时间为 2024 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「migration」 「nova」 「factory」 「laravel」 「seed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cable8mm/xeed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cable8mm/xeed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cable8mm/xeed 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
Lets you add foreign keys in a swift! Foreign key adder in laravel migration.
统计信息
- 总下载量: 2.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 87
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-14
