An open API service indexing awesome lists of open source software.

https://github.com/leafsphp/seedling

🪴 Lightweight console application framework
https://github.com/leafsphp/seedling

Last synced: 4 days ago
JSON representation

🪴 Lightweight console application framework

Awesome Lists containing this project

README

          






Seedling

[![Latest Stable Version](https://poser.pugx.org/leafs/seedling/v/stable)](https://packagist.org/packages/leafs/seedling)
[![Total Downloads](https://poser.pugx.org/leafs/seedling/downloads)](https://packagist.org/packages/leafs/seedling)
[![License](https://poser.pugx.org/leafs/seedling/license)](https://packagist.org/packages/leafs/seedling)

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.

## 📦 Setting Up

You can create a seedling project using the Leaf CLI

```bash
leaf create my-seedling-app --console
```

Or with composer

```bash
composer create-project leafs/seedling my-seedling-app
```

Once installed, Seedling will automatically configure itself, so you can type out `php leaf` to run your app.

## Quick Start

In development, you can always access your commands as well as some built-in seedling commands by running

```bash
php leaf
```

But 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

```bash
./vendor/bin/greeter
```

Or if installed globally

```bash
greeter
```

## Creating Commands

You can create your own commands by using the `g:command` command. For example, to create a `greet` command, you can run

```bash
php leaf g:command greet
```

This will create a new command in the `app/console` directory as `GreetCommand.php`, which will have some boilerplate code to get you started.

```php
argument('name');
$greeting = $this->option('greeting');

$this->info("$greeting, $name!");

return 0;
}
}
```

You can then run your command using

```bash
php leaf greet John --greeting Hi
```