Leaf CLI 2
A simple command line tool for creating and interacting with your leaf projects. You can do stuff like installing packages, interacting with your app, previewing your app, ...
You can get this tool up and running on your system using composer:
composer global require leafs/cli
Make sure to place Composer's system-wide vendor bin directory in your
$PATH so the leaf executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:
- GNU / Linux Distributions:
You could also find the composer's global installation path by running
composer global about and looking up from the first line.
Eg (Adding composer bin to path linux):
Eg (Adding composer bin to path mac):
export PATH=$PATH:$HOME/.composer/vendor/bin echo $PATH
To start a new project, simply open up your console or terminal in your directory for projects and enter:
With leaf 3:
leaf create <project-name> --v3
With leaf 2:
leaf create <project-name> --v2
If no version is passed in, leaf CLI will prompt you to select a version to use in your leaf app.
leaf create <project-name>
* Select a version to use  v3  v2 >
This will now prompt you to select a preset
Creating a new Leaf app "<project-name>" in ./projects-directory. * Please pick a preset  leaf  leaf mvc  leaf api  skeleton >
Selecting a number will generate a leaf app based on the associated preset. As you can see, there are 4 presets:
- Leaf: a bare leaf project
- Leaf MVC: a leaf MVC project with leaf 2
- Leaf API: a leaf API project with leaf 2
- Skeleton: a leaf skeleton project
You can also pick a preset directly without going through the interactive installer.
leaf create <project-name> --basic
leaf create <project-name> --api
leaf create <project-name> --mvc
leaf create <project-name> --skeleton
This cli tool also adds a feature to install modules from composer
leaf install ui
This installs the
You can also install third party packages from packagist
leaf install psr/log
You can also use the interactive shell to interact with your app.
$ leaf interact ... >>> $user = new User; ... >>> $user->name = "Mychi"; ... >>> $user->save();
Previewing your app
This opens up your app on the PHP local server.
You can also specify the port
leaf serve -p 8000
In v2.1, you can also start the leaf server with hot module watching. This reloads your application anytime a change is made to your application code. To get started, simply start the leaf server with the
leaf serve --port 8000 --watch
Leaf CLI is open-sourced software licensed under the MIT license.
We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request
Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.
And to all our existing cash/code contributors, we love you all