Beauty Framework CLI

Maintainers

👁 m1n64

Package info

github.com/beauty-framework/cli

pkg:composer/beauty-framework/cli

Statistics

Installs: 25

Dependents: 6

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2025-06-10 20:29 UTC

Requires

  • php: >=8.1

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 5d6890f52bb72749a9714cdae1f97dd63abec177

clibeauty

This package is not auto-updated.

Last update: 2026-06-24 02:03:30 UTC


README

The beauty-framework/cli package provides a simple, extensible command-line interface (CLI) system for the Beauty Framework. It supports framework-native commands (like code generation, migrations, and cache handling) as well as custom project-defined commands and module-level commands.

Features

  • Command registration via configuration or DI
  • PSR-compatible structure
  • Built-in help/version commands
  • Colorized output with support for info(), warn(), error(), success(), debug() and table()
  • Command auto-discovery and dynamic loading (planned)
  • Code generators (controller, middleware, request, CLI command)
  • Contract for custom registrator class (\Beauty\Cli\Console\Contracts\CommandsRegistryInterface)

CLI Entry Point

Create a beauty executable file in the root of your project:

#!/usr/bin/env php
<?php

use Beauty\Cli\ConsoleKernel;

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/helpers.php';

$commands = require __DIR__ . '/config/cli.php';

$kernel = new ConsoleKernel($commands);
exit($kernel->run($argv));

Make it executable:

chmod +x beauty

Configuration

Define your commands in config/cli.php:

return [
 \Beauty\Cli\Commands\VersionCommand::class,
 \Beauty\Cli\Commands\Generate\ControllerCommand::class,
 \App\Console\Commands\MyCommand::class,
];

Alternatively, load them from modules:

return array_merge(
 [
 \Beauty\Cli\Commands\HelpCommand::class,
 ],
 \Beauty\Orm\OrmCommands::get(),
 \Beauty\Cache\CacheCommands::get(),
);

Base Command API

Extend Beauty\Cli\AbstractCommand:

class MyCommand extends AbstractCommand {
 public function name(): string 
 {
 return 'my:command';
 }
 
 public function description(): string 
 {
 return 'Do something cool';
 }

 public function handle(array $args): int 
 {
 CliOutput::success('It worked!');
 return 0;
 }
}

Use CliOutput for colorized output:

CliOutput::info("Info message");
CliOutput::warn("Warning");
CliOutput::success("Done");
CliOutput::error("Something broke");
CliOutput::table(['ID', 'Name'], [[1, 'User'], [2, 'Admin']]);

Flags like --verbose and --debug are supported automatically.

Code Generators

Run generators via:

php beauty generate:controller User
php beauty generate:command SyncOrders
php beauty generate:middleware Auth
php beauty generate:request Hello

Supports nested directories:

php beauty generate:controller Admin/User

Creates app/Controllers/Admin/UserController.php

Stubs

All generator templates are located in beauty-framework/cli/stubs/. You can override them per project if needed by checking for project-local stub before falling back.

Stub placeholders:

  • {{ namespace }}
  • {{ class }}
  • {{ route }} (in controllers)
  • {{ command_name }} (in CLI commands)

Planned

  • Module auto-discovery for commands
  • Interactive prompts (ask, confirm, choice)
  • Migrations, seeders, testing commands
  • Override stubs

License

MIT