Seedling is a lightweight PHP micro-framework for building CLI apps in minutes. It's built on top of Leaf Sprout and provides a simple and elegant syntax for defining commands, interacting with users, and handling input and output.
You can create a seedling project using the Leaf CLI
leaf create my-seedling-app --consoleOr with composer
composer create-project leafs/seedling my-seedling-appOnce installed, Seedling will automatically configure itself, so you can type out php leaf to run your app.
In development, you can always access your commands as well as some built-in seedling commands by running
php leafBut once you publish your package to composer, your users will be able to run your app using the name of the file in the bin directory. For example, if your file is named greeter, they can run
./vendor/bin/greeterOr if installed globally
greeterYou can create your own commands by using the g:command command. For example, to create a greet command, you can run
php leaf g:command greetThis will create a new command in the app/console directory as GreetCommand.php, which will have some boilerplate code to get you started.
<?php
namespace App\Console;
use Leaf\Sprout\Command;
class GreetCommand extends Command
{
protected $signature = 'greet
{name : The name of the person}
{--greeting=Hello : The greeting to use}';
protected $description = 'An example command that greets a person with a specified greeting';
protected $help = 'This command allows you to greet a person with a custom greeting.';
protected function handle(): int
{
$name = $this->argument('name');
$greeting = $this->option('greeting');
$this->info("$greeting, $name!");
return 0;
}
}You can then run your command using
php leaf greet John --greeting Hi