PHP code example of moox / prompts

1. Go to this page and download the library: Download moox/prompts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moox / prompts example snippets


  use Moox\Prompts\Support\FlowCommand;
  use function Moox\Prompts\text;
  use function Moox\Prompts\select;
  

  class ProjectSetupCommand extends FlowCommand
  {
      protected $signature = 'prompts:project-setup';
      protected $description = 'Project setup wizard (CLI & Web)';
  

      public ?string $environment = null;
      public ?string $projectName = null;
  

      public function promptFlowSteps(): array
      {
          return [
              'stepIntro',
              'stepEnvironment',
              'stepProjectName',
              'stepSummary',
          ];
      }
  

      public function stepIntro(): void
      {
          $this->info('=== Project Setup ===');
      }

      public function stepEnvironment(): void
      {
          $this->environment = select(
              label: 'Which environment do you want to configure?',
              options: [
                  'local' => 'Local',
                  'staging' => 'Staging',
                  'production' => 'Production',
              ],
              default: 'local',
          );
      }

      public function stepProjectName(): void
      {
          $this->projectName = text(
              label: 'What is your project name?',
              placeholder: 'e.g. MyCoolApp',
              validate: '

  public array $features = [];

  public function stepLoggingLevel(): void
  {
      if (! in_array('logging', $this->features, true)) {
          return; // skip step
      }

      // Prompt …
  }
  

  public function stepPublishConfig(): void
  {
      $shouldPublish = confirm(
          label: 'Publish the config now?',
          default: true,
      );

      if (! $shouldPublish) {
          return;
      }

      $this->call('vendor:publish', [
          '--tag' => 'moox-prompts-config',
      ]);
  }
  

    public function stepEnvironment(): void
    {
        $this->environment = select(...);
        $this->info("✅ Environment: {$this->environment}");
    }
    

    public ?bool $publishConfig = null;

    public function stepPublishConfigConfirm(): void
    {
        $this->publishConfig = confirm(
            label: 'Publish the config now?',
            default: true,
        );
    }
    

public function stepPublishConfigConfirm(): void
{
    $this->publishConfig = confirm(
        label: 'Publish the config now?',
        default: true,
    );

    $this->info('✅ Publish config: ' . ($this->publishConfig ? 'yes' : 'no'));
}
bash
php artisan prompts:project-setup
bash
php artisan migrate