承接 axn/laravel-stepper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

axn/laravel-stepper

Composer 安装命令:

composer require axn/laravel-stepper

包简介

Step by step Laravel 5 helper.

README 文档

README

Package that let you create a progress visualization tool step by step (stepper).

Installation

To install Laravel Stepper as a Composer package to be used with Laravel 5, simply run:

composer require axn/laravel-stepper

Once it's installed, the package is automatically registered via Artisan command package:discover (Laravel >=5.5). If not, you must register the service provider in config/app.php by adding this line in providers section:

'Axn\LaravelStepper\ServiceProvider',

Usage

The stepper is going to be used on several pages. There might be several steppers per application, that's why a stepper has to be defined in a dedicated class:

use Axn\LaravelStepper\Stepper;

class BasicStepper extends Stepper
{
    public function register()
    {
        $this->addStep('step 1');
        $this->addStep('step 2');
        $this->addStep('step 3');
        $this->addStep('step 4');
        $this->addStep('step 5');
    }
}

What's important about that class :

  • It extends the abscract class : Axn\LaravelStepper\Stepper
  • It's implementing the register() method
  • It's in that method, that all the different steps are defined

Then, we can inject this class into controller's methods :

    //...

    public function index(BasicStepper $stepper)
    {
        $stepper->setCurrentStepName('step 3');

        return $this->view('example-view', [
            'stepper' => $stepper->render()
        ]);
    }

    //...

Because the class is injected by the IoC container, it's instanciated and the register() is automatically called. After that it's necessary to precise to the stepper which step is the current one : $stepper->setCurrentStepName('step 3'). Then the rendering of the stepper will be transmitted to the view in which you can simply put : {!! $stepper !!}.

Personalize the template

Change the template

This package provides several templates. By default, the template "default" is used. To use the template "arrows", you need to add to the stepper class the name of the template to use:

use Axn\LaravelStepper\Stepper;

class BasicStepper extends Stepper
{
    protected $view = 'stepper::arrows';
    //...
}

That's it!

Of course, in a very classical way, you can use any view of the template system. For example, to use the template resources/views/partials/steppers/custom.blade.php, put the following code in your class:

use Axn\LaravelStepper\Stepper;

class BasicStepper extends Stepper
{
    protected $view = 'partials.steppers.custom';
    //...
}

Personalize a template

All provided templates are more examples to understand how to use the package rather than production templates. For example, CSS styles are embedded in templates, which is not a good practice.

It's possible to start from one of thoose templates provided with the package and to modify them. For that, you have to publish templates, then edit them.

To publish all templates, use the following command:

php artisan vendor:publish

After this step, you'll find all templates in resources/views/vendor/stepper/. It will be very easy to edit them depending on your needs.

Methods in templates

To personalize your templates, different methods are accessible. Here is the list:

Stepper class

{{ $stepper->getStep($stepName) }} return a step, instance of StepInterface, given the name of a step

{{ $stepper->getCurrentStep($stepName) }} return the instance of the current step

{{ $stepper->getPrevStep($stepName) }} return the instance of the previous step

{{ $stepper->getNextStep($stepName) }} return the instance of the next step

{{ $stepper->stepExists($stepName) }} get if a given step with it's name is existing

{{ $stepper->getNumSteps() }} get the total number of steps

{{ $stepper->getCurrentStepName() }} get the name of the current step

The stepper object implements the Iterator's interface, so it's possible to loop easily on it. Every loop is returning an instance of StepInterface implemented by the Step class.

@foreach ($stepper as $step)
    // ...
@endforeach

Step class (StepInterface implementation and more if you wish)

{{ $step->getName() }} return the name associated to the step

{{ $step->getUrl() }} return the URL associated to the step

{{ $step->getRoute() }} return the route associated to the step

{{ $step->getPosition() }} return step's position

{{ $step->getTitle() }} return the title associated to the step

{{ $step->getDescription() }} return the description associated to the step

{{ $step->isCurrent() }} return if it's current step or no

{{ $step->isPassed() }} return if the step is in the past

{{ $step->isFirst() }} return if it's the first step

{{ $step->isLast() }} return if it's the last step

Personalize classes

Because the concrete class of our stepper is a child of the abscract stepper class, it's possible to override properties and methods of that stepper class.

It's also possible to override the Step class very easily by implementing the StepInterface interface and putting in the stepper class the name of the Step class to use:

use Axn\LaravelStepper\Stepper;

class BasicStepper extends Stepper
{
    protected $stepClass = 'App\CustomStep';
    //...
}

axn/laravel-stepper 适用场景与选型建议

axn/laravel-stepper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 994 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 axn/laravel-stepper 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-22