leaf
Command-line tool for scaffolding and managing Leaf PHP projects
TLDR
SYNOPSIS
leaf command [options] [arguments]
DESCRIPTION
leaf is the official command-line companion for the Leaf PHP micro-framework. It scaffolds new applications from curated presets, installs first-party modules and Composer packages, runs a local development server, and exposes an interactive shell for debugging and exploration.The tool wraps composer and the PHP built-in web server, removing the boilerplate of project setup and module wiring. Presets such as --api and --mvc generate a ready-to-run directory layout with routing, environment loading, and module bindings already configured.When run in --watch mode, leaf serve restarts the server on file changes, providing a fast inner-loop for development. leaf interact boots the application and drops the user into a Tinker-style REPL where routes, models, and services can be invoked directly.
PARAMETERS
create name
Scaffold a new Leaf project. Combine with --basic, --api, --mvc, or --custom to choose a preset.install package
Install a Leaf module (e.g. ui, auth, db) or any Composer package into the current project.serve [-p port] [--watch]
Start the built-in PHP development server. -p sets the port, --watch enables hot reload on file changes.interact
Open an interactive REPL bound to the current Leaf application context.test
Run the project test suite.deploy
Trigger a deployment for the current project (depends on configured driver).--basic
Use the bare Leaf 3 starter (router + core only).--api
Use the API-focused preset with routing, validation, and JSON helpers.--mvc
Use the MVC preset (controllers, views, models).--custom
Walk through an interactive setup to pick modules manually.-h, --help
Show help for the CLI or a specific subcommand.-v, --version
Print the installed CLI version.
CONFIGURATION
Installed globally via Composer:
Linux: $HOME/.config/composer/vendor/bin or $HOME/.composer/vendor/bin
macOS: $HOME/.composer/vendor/bin
Windows: %USERPROFILE%\AppData\Roaming\Composer\vendor\binProject-level configuration lives in leaf.config.php (or environment variables loaded from .env). The CLI reads the working directory's composer.json to determine project type and available modules.
CAVEATS
Requires PHP 7.4+ and Composer. The CLI only manages PHP-side dependencies — assets and frontend tooling must still be handled separately (e.g. via npm). The name leaf collides with several unrelated projects (a Go file watcher, a deep learning framework, a terminal markdown previewer); make sure to install the correct package (leafs/cli).
HISTORY
The Leaf PHP framework was created by Michael Darko ("mychi.netlify.app") and the leafsphp organization, with the leaf CLI introduced to streamline project creation and module management. The CLI is published as leafs/cli on Packagist and is distributed under the MIT license.
