Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rreynaldo/baby
Commander CLI micro-framework based on Symfony Console
https://github.com/rreynaldo/baby
cli console framework microframework php7 scheduler symfony
Last synced: 17 days ago
JSON representation
Commander CLI micro-framework based on Symfony Console
- Host: GitHub
- URL: https://github.com/rreynaldo/baby
- Owner: rreynaldo
- License: mit
- Created: 2021-04-26T23:38:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-25T04:52:04.000Z (over 3 years ago)
- Last Synced: 2024-11-18T23:58:22.201Z (3 months ago)
- Topics: cli, console, framework, microframework, php7, scheduler, symfony
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Baby: Commander CLI micro-framework based on Symfony Console (commands, schedules)
[![Baby Logo](https://raw.githubusercontent.com/rreynaldo/baby/main/logo.png)](https://github.com/rreynaldo/baby)
## Install
> composer require rreynaldo/baby
## Script Usage (Similar to Silly): Commander
```php
use Symfony\Component\Console\Output\OutputInterface;$app = new Baby\Application();
$app->command('hello [name] [--yell]', function ($name, $yell, OutputInterface $output) {
if ($name) {
$text = 'Hello, '.$name;
} else {
$text = 'Hello';
}
if ($yell) {
$text = strtoupper($text);
}
$output->writeln($text);
});
$app->run();
```## Running
Running the application is the same as running any other Symfony Console application:
```bash
$ php app.php hello
$ php app.php hello john --yell
$ php app.php hello --yell john
```### Project Usage (Recommended user Baby Skeleton):
```php
useContainer($container);
//Register Schedules (Schedules)
$app->schedule(new AppTestSchedule($container));//Register commands (Standar Symfony Commands in your project)
$app->add(new AppTestCommand($container));//run App
$app->run();
```## Commands
```php
container = $container;
}protected function execute(InputInterface $input, OutputInterface $output): int
{
return Command::SUCCESS;
}
}```
## Schedules
```php
container = $container;
}protected function initialize(Schedule $schedule)
{
$schedule->everyMinutes(1);
}public function run()
{
print_r("everyMinutes");
}
}
```## Available Commands
```bash
Usage:
command [options] [arguments]Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debugAvailable commands:
help Display help for a command
list List commands
app
app:test:command
baby
baby:schedule-run Run due tasks
baby:scheduler-list List the existing schedules
baby:scheduler-start Starts command scheduler
baby:scheduler-stop Stops command scheduler
```