← 返回命令列表

Linux command

leaf 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create

leaf create [my-app]

Create

leaf create [my-app] --basic

Create

leaf create [my-app] --api

Create

leaf create [my-app] --mvc

Install

leaf install [package_name]

Start

leaf serve -p [8000]

Start

leaf serve --watch

Open

leaf interact

说明

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.

参数

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.

FAQ

What is the leaf command used for?

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.

How do I run a basic leaf example?

Run `leaf create [my-app]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does create _name_ do in leaf?

Scaffold a new Leaf project. Combine with --basic, --api, --mvc, or --custom to choose a preset.