james.rus52/laravel-wizard
Composer 安装命令:
composer require james.rus52/laravel-wizard
包简介
Wizard component for laravel.
README 文档
README
simple laravel step-by-step wizard
| Version | Laravel Version | Php Version |
|---|---|---|
| 1.1 | 5.* | ^7.0 |
| ^2.0 | 6.* || 7.* || 8.* | ^7.2 |
Install
$ composer require james.rus52/laravel-wizard
Example/How
-
add routes
Route::get('/create/{step?}', [\App\Http\Controllers\CreationRequestsController::class, 'create']) ->name('requests.create'); Route::post('/create/{step}', [\App\Http\Controllers\CreationRequestsController::class, 'store']) ->name('requests.store');
-
create steps
create step class
class InformationStepWizard extends \jamesRUS52\Laravel\Step { public function process(Request $request) { $this->saveProgress($request); } public function getAuxData(): array { return [ 'owners' => 'Some extra data for view on this step', ]; } public function rules(Request $request = null): array { return [ 'owner' => 'required', ]; } }
-
create controller
class CreationRequestsController extends Controller { protected Wizard $wizard; public function __construct() { $this->wizard = new Wizard('Request wizard', [ new InformationStepWizard('information', 'Information', 'requests.create.information-step-wizard'), new RequestTypeStepWizard('request-type', 'Request type', 'requests.create.request-type-step-wizard'), new ResourcesStepWizard('resources', 'Choose resources', 'requests.create.resources-step-wizard'), new ConfirmationStepWizard('confirmation', 'Confirmation', 'requests.create.confirmation-step-wizard'), ], 'creation-request' ); } public function create($step_slug = null) { try { if (is_null($step_slug)) { $step = $this->wizard->firstOrLastProcessed(); } else { $step = $this->wizard->getBySlug($step_slug); } } catch (StepNotFoundException $e) { abort(404); } return view('requests.create.layout-wizard', array_merge([ 'type' => 'creation', ], $step->getAuxData(), ) ); } public function store(Request $request, $step_slug = null) { try { $step = $this->wizard->getBySlug($step_slug); } catch (StepNotFoundException $e) { abort(404); } $this->validate($request, $step->rules($request)); $step->process($request); if ($this->wizard->hasNext()) { return redirect()->route('requests.create.', [$this->wizard->nextStep(false)->slug]); } // Finaly Create Request $full_wizard_data = $this->wizard->data(); $this->wizard->clearProgress(); return redirect()->route('requests.index'); } }
-
add base view $wizard variable is now automatic sheared with view Layout wizard template
<h4>{{$wizard->getTitle()}}</h4> <div class="container container-fluid mt-4 mb-5"> <div class="row"> @foreach($wizard->getSteps() as $step) <div class="col text-center"> @if($step->index == $wizard->currentStep()->index) <strong>{{ $step->label }}</strong> @elseif($wizard->currentStep()->index > $loop->index) <a class="text-primary" href="{{ route('requests.create.'.$type, [$step->slug]) }}">{{ $step->label }}</a> @else {{ $step->label }} @endif </div> @endforeach </div> <div class="progress m-2"> <div class="progress-bar" role="progressbar" style="width: {{$wizard->completionPercent()}}%;" aria-valuenow="{{$wizard->completionPercent()}}" aria-valuemin="0" aria-valuemax="100">{{$wizard->completionPercent()}}%</div> </div> </div> <form action="{{ route('requests.store.'.$type, [$wizard->currentStep()->slug]) }}" method="POST" novalidate> @csrf <div class="container mt-5"> <div class="row justify-content-center"> <div class="col-12 col-lg-9"> @include($wizard->currentStep()->view, ['step' => $wizard->currentStep(), 'errors' => $errors]) </div> </div> <div class="row justify-content-center"> @if ($wizard->hasPrev()) <div class="col-2 text-right"> <a class="btn btn-primary" href="{{ route('requests.create.'.$type, ['step' => $wizard->prevStep(false)->slug]) }}">Back</a> </div> @endif <div class="col-2 text-center pt-2"> Step {{ $wizard->currentStep()->getNumber() }} of {{ $wizard->stepsCount() }} </div> <div class="col-2 text-left"> @if ($wizard->hasNext()) <button class="btn btn-primary" type="submit">Next</button> @else <button class="btn btn-primary" type="submit">Finish</button> @endif </div> </div> </div> </form>
License
Laravel wizard is open-sourced software licensed under the MIT license
james.rus52/laravel-wizard 适用场景与选型建议
james.rus52/laravel-wizard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wizard」 「steps」 「laravel」 「step」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 james.rus52/laravel-wizard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 james.rus52/laravel-wizard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 james.rus52/laravel-wizard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides methods to create, validate and render HTML forms in PHP.
A web setup wizard for Laravel application.
Site generator / tree model duplicator used to generate mini-website or duplicate tree model
A PHP package to determine steps and progress.
A Codeception adapter for Allure report.[NON OFFICIAL FORK!]
Multi step wizard widget using tabs to guide a user through steps to complete a task. Based on the Form wizard (using tabs) from lukepzak (see http://bootsnipp.com/snippets/featured/form-wizard-using-tabs).
统计信息
- 总下载量: 81
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-11
