Leaf + MVC
Leaf MVC
Structure for real apps, without the framework weight.
Leaf MVC gives your project controllers, models, routes, views, services, and environment conventions from day one, while keeping the codebase small enough for humans and AI assistants to understand.
1 map
for humans and AI
0 lock-in
just PHP
Best for
Products with real users
Dashboards, portals, CMS projects, admin tools, and apps that need room to grow.
Teams and AI assistants
A predictable code map makes changes easier to review, extend, and generate.
APIs and full-stack apps
Keep backend logic organized while using the frontend stack you already like.
What is MVC?
MVC stands for Model-View-Controller. It separates your application into the parts that hold data, display interfaces, and respond to requests.
New to MVC?
MVC is a simple way to keep application code organized. Models talk to data, views present the interface, and controllers coordinate requests. Traversy Media has a useful overview if you want a broader introduction before building with Leaf.
MVC in Leaf
Leaf MVC is a minimal setup for building structured applications. It adds the folders and commands most projects need, but avoids forcing your app into a heavy framework model.
Request flow
A route receives the request, a controller decides what should happen, models and services handle the work, and a view or JSON response returns the result. That predictable flow is why Leaf MVC works well for teams and AI-assisted changes.
app()->get('/dashboard', 'DashboardController@index');return response()->view('dashboard', [
'data' => db()->select('frames')->get()
]);<h1>Dashboard</h1>
<ul>
@foreach ($data as $frame)
<li>{{ $frame->name }}</li>
@endforeach
</ul>Directory Structure
Leaf MVC's directory structure is inspired by Rails and Laravel, but it stays lightweight and flexible. A fresh app starts with the places most product code naturally belongs.
Default starter
app/
Your controllers, models, views, routes, database files, and application logic.
public/
The only browser-exposed directory, usually for bundled CSS, JavaScript, and images.
Modules may also generate folders like storage for logs, cache, and temporary files.
Configuring Leaf MVC
Leaf MVC works out of the box. Most projects only need a few environment variables, so there is no config directory until you publish one.
appcore app behaviorauthauthenticationdatabasedatabase connectionsviewview renderingmailmail deliveryqueuequeued jobscorscross-origin requestscsrfCSRF protectionApplication Environment
Leaf MVC ships with a .env.example file that is copied to .env during installation. Values are automatically loaded and available through the _env() helper.
$database = _env('DB_DATABASE');
$databaseWithDefault = _env('DB_DATABASE', 'leaf');Do not commit your .env file. Leaf MVC already adds it to .gitignore because it can contain database credentials, API keys, and other secrets.
Building with Leaf MVC
Leaf MVC gives you structure without taking away your choices. Build a full-stack app, serve a frontend with Inertia or Blade, or expose a clean JSON API for any client.
