crestapps/laravel-code-generator
Composer 安装命令:
composer require crestapps/laravel-code-generator
包简介
An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cr
关键字:
README 文档
README
Introduction
An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.
For full documentation and live demo please visit CrestApps.com
Features
- Craft clean, reusable, and highly readable code for seamless development.
- Generate complete resources effortlessly with a single command, supporting both migration and existing database scenarios.
- Streamline resource creation for all existing database tables with a single command.
- Save and recreate fields using a JSON file, ensuring adaptability to changing business needs.
- Leverage JSON-based resource files for easy regeneration, even when business rules evolve.
- Generate standard CRUD controllers with simple or form-request validation.
- Customize view templates to alter the standard look and feel of your application.
- Create models with relations for comprehensive data representation.
- Establish named routes with and without grouping for efficient navigation.
- Generate standard CRUD views to facilitate a consistent user experience.
- Smart migration engine tracks generated migrations to only create necessary ones.
- Intelligent handling of model relations to simplify development.
- Highly flexible with rich configurable options to suit diverse needs.
- Easy commands for resource-file creation, addition, or reduction.
- Full support for generating multi-language applications.
- Implement client-side validation for enhanced user interaction.
- Efficiently handle file uploading and store multiple responses in the database.
- Generate form-request to clean up controllers and boost code reusability.
- Create view layouts with and without client-side validation.
- Change templates at runtime for diverse view generation.
- Ability to generate views with or without Laravel-Collective integration.
- Seamless handling of date, time, or datetime fields.
- Automatic management of boolean fields for hassle-free development.
Installation
-
To download this package into your Laravel project, use the command-line to execute the following command
composer require crestapps/laravel-code-generator --dev -
(You may skip this step when using Laravel >= 5.5) To bootstrap the packages into your project while using command-line only, open the app/Providers/AppServiceProvider.php file in your project. Then, add the following code to the register() method.
Add the following line to bootstrap
laravel-code-generatorto the framework.if ($this->app->runningInConsole()) { $this->app->register('CrestApps\CodeGenerator\CodeGeneratorServiceProvider'); }
Lessons
Checkout our channel on YouTube.com
Available Commands
The command in between the square brackets [] must be replaced with a variable of your choice.
-
Main commands
- php artisan create:scaffold [model-name]
- php artisan create:controller [model-name]
- php artisan create:model [model-name]
- php artisan create:form-request [model-name]
- php artisan create:routes [model-name]
- php artisan create:migration [model-name]
- php artisan create:language [model-name]
- php artisan create:mapped-resources
-
API commands
- php artisan create:api-scaffold [model-name]
- php artisan create:api-controller [model-name]
- php artisan create:api-resources [model-name]
-
API Documentations commands
- php artisan api-docs:scaffold [model-name]
- php artisan api-doc:create-controller [model-name]
- php artisan api-doc:create-view [model-name]
-
Views commands
- php artisan create:layout [application-name]
- php artisan create:views [model-name]
- php artisan create:index-view [model-name]
- php artisan create:create-view [model-name]
- php artisan create:edit-view [model-name]
- php artisan create:show-view [model-name]
- php artisan create:form-view [model-name]
-
Resource's files commands
- php artisan resource-file:from-database [model-name]
- php artisan resource-file:create [model-name]
- php artisan resource-file:append [model-name]
- php artisan resource-file:reduce [model-name]
- php artisan resource-file:delete [model-name]
-
Migration commands
- php artisan migrate-all
- php artisan migrate:rollback-all
- php artisan migrate:reset-all
- php artisan migrate:refresh-all
- php artisan migrate:status-all
Contribution
Are you interested in supporting this project and making a contribution? Here's how you can get involved:
- Begin by showing your appreciation for this package on GitHub by giving it a star.
- Share this project with others to encourage ongoing enhancements and the introduction of new features.
- Report any bugs, provide comments, share ideas, or express your thoughts about this project by creating an issue on GitHub.
- Contributors are encouraged! If you're passionate about this project, consider addressing existing issues by submitting a pull request.
- If possible, consider sponsoring the project.
What did you create with this package?
I'd love to know if your site was generated using this package and list your logo on the documentation site. Please email using my contact info found in composer.json file.
Examples
The following example assumes that we are trying to create a CRUD called AssetCategory with the fields listed below.
- id
- name
- description
- is_active
Basic example - CRUD with migration
php artisan resource-file:create AssetCategory --fields=id,name,description,is_activeThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
php artisan create:scaffold AssetCategory --with-migrationThe above command will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and migration class!
Basic example - CRUD with migration - Shortcut
php artisan create:scaffold AssetCategory --with-migration --fields=id,name,description,is_activeThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json first. Then, it will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and migration class!. This is a short way to issuing both `resource-file:create` and `create:scaffold` in one line
Basic API example - CRUD with migration
php artisan resource-file:create AssetCategory --fields=id,name,description,is_activeThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
php artisan create:scaffold AssetCategory --with-migrationThe above command will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and migration class!
Basic example using translations for English and Arabic - with migration
php artisan resource-file:create AssetCategory --fields=id,name,description,is_active --translation-for=en,arThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
php artisan create:scaffold AssetCategory --with-migrationThe above command will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and migration class!
Basic example with form-request
php artisan resource-file:create AssetCategory --fields=id,name,description,is_activeThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
php artisan create:scaffold AssetCategory --with-form-requestThe above command will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and app/Http/Requests/AssetCategoriesFormRequest class!
Basic example with soft-delete and migration
php artisan resource-file:create AssetCategory --fields=id,name,description,is_activeThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
php artisan create:scaffold AssetCategory --with-soft-delete --with-migrationThe above command will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views, the routes, and migration file!
Creating resources from existing database
php artisan create:scaffold AssetCategory --table-existsThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json. It is going to assume that the table name is called "asset_categories" in your database. If that is not the case, you can use --table-name=some_other_table_name
Then it will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views and the routes!
You may also create a resource-file from existing database separately using
php artisan resource-file:from-database AssetCategory
Creating resources from existing database with translation for English and Arabic
php artisan create:scaffold AssetCategory --translation-for=en,ar --table-existsThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
Then it will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views and the routes!
You may also create a resource-file from existing database separately using
php artisan resource-file:from-database AssetCategory --translation-for=en,ar
Creating resources from existing database with translation for English and Arabic in two step for better control over the fields!
php artisan resource-file:from-database AssetCategory --translation-for=en,ar
php artisan create:scaffold AssetCategoryThe above command will create resource-file names /resources/laravel-code-generator/sources/asset_categories.json
Then it will create a model app/Models/AssetCategory, a controller app/Http/Controllers/AssetCategoriesController, all views and the routes!
s
License
"Laravel Code Generator" is an open-sourced software licensed under the MIT license
crestapps/laravel-code-generator 适用场景与选型建议
crestapps/laravel-code-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 96.3k 次下载、GitHub Stars 达 761, 最近一次更新时间为 2016 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「code generator」 「crud」 「laravel」 「crud generator」 「generators」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 crestapps/laravel-code-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 crestapps/laravel-code-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 crestapps/laravel-code-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Promotional Codes Generator for Laravel 5.1
Collection of tools to use the full power of the Enyalius framework
统计信息
- 总下载量: 96.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 769
- 点击次数: 35
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-31