hcesrl / laravel-wizartisan
Build your custom Laravel Artisan wizard commands.
v0.1.0
2019-05-28 10:15 UTC
Requires
- php: >=7.0
- illuminate/console: >=5.5
- illuminate/contracts: >=5.5
- illuminate/support: >=5.5
- illuminate/validation: >=5.5
Requires (Dev)
- orchestra/testbench: ^3.8
This package is auto-updated.
Last update: 2025-01-28 23:43:11 UTC
README
Installation
Install the package:
composer require hcesrl/laravel-wizartisan
Usage
Create your wizard command extending the Wizartisan command. You must implement the configureWizard
to add the
steps to the wizard and the finish
method that receives the validated data and completes the procedure.
<?php namespace App\Console\Commands; use Wizartisan\Command; class CustomCommand extends Command { protected function configureWizard () { /** * Ask simple question with validation */ $this->askQuestion ( 'What is your name?' ) ->name ( 'name' ) ->mustValidate ( 'required' ); /** * Select option from given set */ $this->askQuestion ( 'Choose your option:' ) ->name ( 'option' ) ->chooseFrom ( [ 'option1' => 'Option 1', 'option2' => 'Option 2', 'option3' => 'Option 3', ] ); /** * Ask a question with confirmation and hide the answer */ $this->askQuestion ( 'What is your secret password?' ) ->name ( 'password' ) ->hideAnswer () ->withConfirmation ( 'You must confirm your password' ); } protected function finish ( $data = [] ) { $this->doSomethingWithTheValidInputData ( $data ); return 0; } }
License
This package is open-sourced software licensed under the MIT license.