Install the CLI, create a project
| [ Web Proxy ] |
| Viewing: https://leafphp.dev/learn/basic | [Back] [Original] |
Leaf 5 is here/A product-first PHP framework for the AI era.
Explore what's newWhat's newSome projects are just a few pages, a webhook, or a small API. Leaf is designed to let you start with the simplest structure that works and grow as the product needs it.
Install the CLI, create a project
Run it
Your app is live athttp://localhost:5500
Need more structure? leaf create my-app --mvc gives you controllers, views and models up front. Everything else stays optional.
A lite project starts with enough structure to handle real requests without putting a framework ceremony between you and the product.
<?php
require __DIR__ . '/vendor/autoload.php';
app()->get('/', fn () => response()->json([
'message' => 'Hello from Leaf'
]));
app()->run();Leaf CLI creates a .leaf/CONTEXT.md file with context about your project. When using a coding assistant in your editor or terminal, ask it to read that file before making changes.
For example, if you tell your agent to implement a new messaging feature, it will automatically read the context from .leaf/CONTEXT.md and make changes that fit the existing project structure, and if your assistant cannot access the project folder, run:
leaf contextPaste the output into your conversation along with your request. See AI in Leaf for more on project context.
Leaf modules add focused features without replacing your starting point.
leaf install auth db mailOnce installed, modules use the same concise Leaf style:
auth()->login($credentials);
$user = db()
->select('users')
->where('email', $email)
->first();
mailer()
->to($user->email)
->send('welcome');You do not need to predict the final architecture on day one. Choose the amount of structure the product needs now.
All three stages stay inside Leaf, so growth does not require a framework rewrite.
Leaf has no private runtime or hosting lock-in. Deploy to a VPS, shared hosting, containers, or a managed PHP platform using the same application you built locally.
When structure becomes useful
The same project can grow into Leaf MVC.Keep the ecosystem, add the application map.Choose the part of the stack your next feature needs.
Updated at:
| Web Proxy Viewer | New URL | Original Page |