marcpacuri/l5scaffold 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

marcpacuri/l5scaffold

Composer 安装命令:

composer require marcpacuri/l5scaffold

包简介

Extend Laravel 5's generators using Semantic UI scaffolding.

README 文档

README

Hi, this is a forked scaffold generator for Laravel 5.2. using Semantic UI styles instead of Bootstrap

Usage

Step 1: Install Through Composer

composer require 'robbielove/l5scaffold' --dev

install landish/pagination in your project - this project uses it for pagination Controllers

composer require landish/pagination

Step 2: Add the Service Provider

Open config/app.php and, to your providers array at the bottom, add:

        laralib\L5scaffold\GeneratorsServiceProvider::class,

Step 3: Run Artisan!

You're all set. Run php artisan from the console, and you'll see the new commands make:scaffold.

If you would like a Semantic UI based layout; Rename the generated layout.blade.php to app.blade.php, create a folder called layouts in the resources/views folder, place the app.blade.php template in there. Modify this template to your own needs. all generated scaffolds use this template.

If you want to use it for your entire app simply return the layouts.app view to index routes (app/Http/Controllers/HomeController.php):

public function index()
    {
        return view('layouts.app');
    }

Examples

Ensure you include at least 1 field for the schema to generate or you will get an 'array to string' conversion error.

(Don't include the default fields: id, name, description, slug, active_flag, author_id, timestamps)

php artisan make:scaffold Object \
  --ui="sui2" \
	--schema="title:string:default('Object 1'), body:text" \

Always use the plural version of your prefix:

php artisan make:scaffold Object \
  --ui="sui2" \
	--schema="title:string:default('Object 1'), body:text" \
	--prefix="settings"

You can also use the old Bootstrap styles if you prefer

php artisan make:scaffold Object \
  --ui="bs3" \
	--schema="title:string:default('Object 1'), body:text" \
	--prefix="settings"

These commands will generate:

app/Object.php
app/Http/Controllers/ObjectController.php
database/migrations/201x_xx_xx_xxxxxx_create_objects_table.php
database/seeds/ObjectTableSeeder.php
resources/views/layout.blade.php
resources/views/objects/index.blade.php
resources/views/objects/show.blade.php
resources/views/objects/edit.blade.php
resources/views/objects/create.blade.php

The generated migration will include by default:

$table->increments('id');
$table->string('name')->default('Un-Named Object');
$table->string('slug');
$table->text('description');

[Your custom fields]

$table->boolean('active_flag');
$table->integer('author_id')->unsigned()->default(0);
$table->foreign('author_id')->references('id')->on('users');
$table->timestamps();

And you will need to run the migration after ensuring it is correct;

php artisan migrate

Scaffold updating and customisation

After migrating you should add the fields that you added to the schema, to the controller as they are not added during the scaffold process. Ensure you add them to the create and update methods and include in validation if needed. The default fields will work out-the-box.

If you have created the scaffold with a prefix - you will need to tweak some of the views as they will not quite match up to the values the controller is expecting.

The stubs use the model name to add the icon also, in most cases this will not match up with a Semantic UI icon in which case you will need to choose one and then modify the scaffolds with the new icon name

The icons next to the fields shown on the create, edit and show views are also using the field name so you will likely want to customise these too. the default 'Name' field uses the Object icon.

Semantic UI icons

Add your Routes to app/Http/routes.php

Route::bind('objects', function($value, $route) {
  return App\Object::whereSlug($value)->firstOrFail();
});
Route::resource("objects","ObjectController");

with prefix: (in some cases you may want to leave off some views such as index and create views) use the previous code if you use prefix groups since the prefix encloses that code instead.

if you are prefixing a top level object, make sure you place your prefixed routes above the top level pattern to avoid Laravel from skipping those routes and returning 404 errors (bit of a gotcha)

Route::bind('objects', function($value, $route) {
  return App\Object::whereSlug($value)->firstOrFail();
});
Route::resource('prefixes.objects', 'ObjectController',['except' => ['index'],['create']]);

Custom stub

Create a new folder inside Stubs > views with your UI name as the folder name

Custom fields in Stubs > views > **ui-name** > fields

Custom pages in Stubs > views > **ui-name** > pages

marcpacuri/l5scaffold 适用场景与选型建议

marcpacuri/l5scaffold 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「scaffold」 「laravel」 「generators」 「laravel5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 marcpacuri/l5scaffold 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 110
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-28