[ Web Proxy ]
URL:
Viewing: https://leafphp.dev/learn/basic [Back]  [Original]

Start simple. Ship fast. | Leaf PHP
Skip to content
Menu
Return to top
Sidebar Navigation SearchK
On this page
    CREATIVE LEAF

    We build products too.

    From the creators of Leaf PHP, a studio that's shipped frameworks and products used by millions. Let's build yours.

    Start your project
    Open with AI

    Start simple. Ship fast.

    Some 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.

    // Quickstart
    Bashcopy all
    01

    Install the CLI, create a project

    composer global require leafs/cli
    leaf create my-app
    copy
    02

    Run it

    cd my-app && leaf serve
    copy
    03

    Your app is live athttp://localhost:5500

    ~30s
    ThenAdd your first route app()->get('/', fn() => ...)Pull in a module leaf install auth

    Need more structure? leaf create my-app --mvc gives you controllers, views and models up front. Everything else stays optional.

    The smallest useful Leaf app

    A lite project starts with enough structure to handle real requests without putting a framework ceremony between you and the product.

    php
    <?php
    
    require __DIR__ . '/vendor/autoload.php';
    
    app()->get('/', fn () => response()->json([
      'message' => 'Hello from Leaf'
    ]));
    
    app()->run();
    01 / RouteMatch the requestConnect an HTTP method and URL to the behavior your application needs.
    02 / LogicWrite the useful partWhen your route matches, implement the necessary logic to handle the request.
    03 / ResponseReturn clean outputSend JSON, HTML, redirects, downloads, or any response the client expects.

    Working with an AI assistant

    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:

    bash
    leaf context

    Paste the output into your conversation along with your request. See AI in Leaf for more on project context.

    Add capabilities when the product asks

    Leaf modules add focused features without replacing your starting point.

    bash
    leaf install auth db mail

    Once installed, modules use the same concise Leaf style:

    php
    auth()->login($credentials);
    
    $user = db()
        ->select('users')
        ->where('email', $email)
        ->first();
    
    mailer()
        ->to($user->email)
        ->send('welcome');

    Grow at your own pace

    You do not need to predict the final architecture on day one. Choose the amount of structure the product needs now.

    01 / LiteProve the ideaUse a small entry point for scripts, experiments, webhooks, APIs, and focused tools.
    02 / ModulesAdd capabilitiesBring in authentication, data, mail, billing, queues, or caching as requirements appear.
    03 / MVCOrganize the productMove into controllers, models, views, services, and conventions when the team or app needs them.

    All three stages stay inside Leaf, so growth does not require a framework rewrite.

    Deploy anywhere PHP runs

    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.
    Continue to MVC

    Choose the part of the stack your next feature needs.


    Web Proxy Viewer  |  New URL  |  Original Page