Leaf + MVC โ
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 and cache, as well as 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 behavior
authauthentication
databasedatabase connections
viewview rendering
mailmail delivery
queuequeued jobs
corscross-origin requests
csrfCSRF protection
Application 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.
