定制 squatto/grafite-crudmaker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

squatto/grafite-crudmaker

Composer 安装命令:

composer require squatto/grafite-crudmaker

包简介

An incredibly powerful and some say magical CRUD maker for Laravel

README 文档

README

IMPORTANT: this fork's entire purpose is to enable compatibility with Laravel 8.x and beyond.
OUTSIDE OF ENSURING COMPATIBILITY, NO FEATURE ADDITIONS/CHANGES OR BUG FIXES WILL BE MADE!

CrudMaker - An incredibly powerful and some say magical CRUD maker for Laravel

license

It can generate magical CRUD prototypes rapidly with full testing scripts prepared for you, requiring very little editing. Following SOLID principals it can construct a basic set of components pending on a table name provided in the CLI. The CRUD can be used with singular table entities think: 'books' or 'authors' but, you can also build CRUDs for combined entities that is a parent, and child like structure: 'books_authors'. This will generate a 'books_authors' table and place all components of the authors (controller, service, model etc) into a Books namespace, which means you can then generate 'books_publishers' and have all the components be added as siblings to the authors. Now let's say you went ahead with using the Laracogs starter kit, then you can autobuild your CRUDs with them bootstrapped, which means they're already wrapped up as view extensions of the dashboard content which means you're even closer to being done your application.

Author(s):

Requirements

  1. PHP 7.3+
  2. OpenSSL
  3. Laravel 8.0+

Compatibility and Support

Laravel Version Package Tag Supported
8.x 1.7.x no
7.x 1.6.x no
6.x 1.5.x no
5.6.x 1.4.x no
5.5.x 1.3.x no
5.4.x 1.2.x no
5.3.x 1.1.x no

Documentation

php artisan crudmaker:new {name or snake_names}
{--api}
{--ui=bootstrap}
{--serviceOnly}
{--withBaseService}
{--withFacade}
{--withoutViews}
{--migration}
{--schema}
{--relationships}

Config

The config is published in config where you can specify namespaces, locations etc.

Templates

All generated components are based on templates. There are basic templates included in this package, however in most cases you will have to conform them to your project's needs. If you have published the assets during the installation process, the template files will be available in resources/crudmaker/crud.

Test templates are treated differently from the other templates. By default there are two test templates provided, one integration test for the generated service, and one acceptance test. However, the Tests folder has a 'one to one' mapping with the tests folder of your project. This means you can easily add tests for different test levels matching your project. For example, if you want to create a unit test for the generated controller, you can just create a new template file, for instance resources/crudmaker/crud/Tests/Unit/ControllerTest.txt. When running the CRUD generator, the following file will then be created: tests/unit/NameOfResourceControllerTest.php.

API

The API option will add in a controller to handle API requests and responses. It will also add in the API routes assuming this is v1.

yourapp.com/api/v1/books

UI

There is only one supported CSS framework (Bootstrap). Without the UI option specified the CrudMaker will use the plain HTML view which isn't very nice looking.

Both expect a dashboard parent view, this can be generated with the following commands:

php artisan grafite:build bootstrap

These re-skin your views with either of the CSS frameworks.

Service Only

The service only will allow you to generate CRUDs that are service layer and lower this includes: Service, Model, and Tests with the options for migrations. It will skip the Controllers, Routes, Views, etc. This keeps your code lean, and is optimal for relationships that don't maintain a 'visual' presence in your site/app such as downloads of an entity.

With Base Service

If you opt in for this the CrudMaker will generate a BaseService which this CRUD's service will extend from. This can be handy when you want to reduce code duplication.

With Facades

If you opt in for Facades the CRUD will generate them, with the intention that they will be used to access the service. You will need to bind them to the app in your own providers, but you will at least have the Facade file generated.

Migration

The migration option will add the migration file to your migrations directory, using the schema builder will fill in the create table method. The Schema and Relationships require this since they expect to modify the migration file generated.

Schema

Requires migration option

You can define the table schema with the structure below. The field types should match what would be the Schema builder.

--schema="id:bigIncrements,name:string"

The following column types are available:

  • bigIncrements
  • increments
  • bigInteger
  • binary
  • boolean
  • char
  • date
  • dateTime
  • decimal
  • double
  • enum
  • float
  • integer
  • ipAddress
  • json
  • jsonb
  • longText
  • macAddress
  • mediumInteger
  • mediumText
  • morphs
  • smallInteger
  • string
  • text
  • time
  • tinyInteger
  • timestamp
  • uuid

Want further definitions?

--schema="id:bigIncrements|first,user_id:integer|unsigned,name:string|nullable|after('id'),age:integer|default(0)"

You can even handle some parameters such as:

--schema="id:bigIncrements|first,user_id:integer|unsigned,name:string(45)"

Relationships

Requires migration option

You can specify relationships, in order to automate a few more steps of building your CRUDs. You can set the relationship expressions like this:

relation|class|column

or something like:

hasOne|App\Author|author

This will add in the relationships to your models, as well as add the needed name_id field to your tables. Just one more thing you don't have to worry about. The general relationships handled by the HTML rendered are:

hasOne
hasMany
belongsTo

!!! warning "The CRUD currently doesn't support belongsToMany that is to say it does not currently create a relational table"

Examples

The following components are generated:

Files Generated

  • Controller
  • Api Controller (optional)
  • Service
  • CreateRequest
  • UpdateRequest
  • Model
  • Facade (optional)
  • Views (Bootstrap or Semantic or CSS framework-less)
  • Tests
  • Migration (optional)

Appends to the following Files:

  • app/Http/routes.php
  • database/factories/ModelFactory.php

Single Word Example (Book):

php artisan crudmaker:new Book
--migration
--schema="id:bigIncrements,title:string,author:string"

When using the default paths for the components, the following files will be generated:

  • app/Http/Controllers/BookController.php
  • app/Http/Requests/BookCreateRequest.php
  • app/Http/Requests/BookUpdateRequest.php
  • app/Models/Book/Book.php
  • app/Services/BookService.php
  • resources/views/book/create.blade.php
  • resources/views/book/edit.blade.php
  • resources/views/book/index.blade.php
  • resources/views/book/show.blade.php
  • database/migrations/create_books_table.php
  • tests/BookIntegrationTest.php
  • tests/BookServiceTest.php

Snake Name Example (Book_Author):

php artisan crudmaker:new Book_Author
--migration
--schema="id:bigIncrements,firstname:string,lastname:string"
--withFacade

When using the default paths for the components, the following files will be generated:

  • app/Facades/Books/AuthorServiceFacade.php
  • app/Http/Controllers/Books/AuthorController.php
  • app/Http/Requests/Books/AuthorCreateRequest.php
  • app/Http/Requests/Books/AuthorUpdateRequest.php
  • app/Models/Books/Author/Author.php
  • app/Services/Books/AuthorService.php
  • resources/views/book/author/create.blade.php
  • resources/views/book/author/edit.blade.php
  • resources/views/book/author/index.blade.php
  • resources/views/book/author/show.blade.php
  • database/migrations/create_book_authors_table.php
  • tests/Books/AuthorIntegrationTest.php
  • tests/Books/AuthorServiceTest.php

Single Name Example (Book with API):

php artisan crudmaker:new Book
--api
--migration
--schema="id:bigIncrements,title:string,author:string"

When using the default paths for the components, the following files will be generated:

  • app/Http/Controllers/Api/BookController.php
  • app/Http/Controllers/BookController.php
  • app/Http/Requests/BookCreateRequest.php
  • app/Http/Requests/BookUpdateRequest.php
  • app/Models/Book/Book.php
  • app/Services/BookService.php
  • resources/views/book/create.blade.php
  • resources/views/book/edit.blade.php
  • resources/views/book/index.blade.php
  • resources/views/book/show.blade.php
  • database/migrations/create_books_table.php
  • tests/BookIntegrationTest.php
  • tests/BookServiceTest.php

This is an example of what would be generated with the CRUD builder. It has all basic CRUD methods set.

Table CRUD

The table CRUD is a wrapper on the CRUD which will parse the table in the database and build the CRUD from that table.

You must make sure the name matches the table name case wise

php artisan crudmaker:table {name or snake_names}
{--api}
{--ui=bootstrap}
{--serviceOnly}
{--withFacade}
{--relationships}

License

CrudMaker is open-sourced software licensed under the MIT license

Bug Reporting and Feature Requests

Please add as many details as possible regarding submission of issues and feature requests

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

squatto/grafite-crudmaker 适用场景与选型建议

squatto/grafite-crudmaker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 squatto/grafite-crudmaker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 squatto/grafite-crudmaker 我们能提供哪些服务?
定制开发 / 二次开发

基于 squatto/grafite-crudmaker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-19