Skip to content

Directory Structure

Overview

A typical Lighthouse application:

my-app/
├── config/
│   └── app.php
├── public/
│   ├── index.php
│   └── .htaccess
├── routes/
│   └── web.php
├── src/
│   └── Controllers/
│       └── HomeController.php
├── views/
│   ├── layouts/
│   │   └── main.php
│   ├── home.php
│   └── about.php
├── tests/
├── .env
├── .env.example
└── composer.json

Directory Purpose

config/

Application configuration files.

php
// config/app.php
return [
    'name' => 'My App',
    'debug' => true,
];

public/

The web server's document root. Contains index.php (the entry point) and static assets.

Only this directory should be publicly accessible.

routes/

Route definitions.

php
// routes/web.php
$app->get('/', [HomeController::class, 'index']);
$app->get('/about', [HomeController::class, 'about']);

src/

Your application code — controllers, services, models.

php
// src/Controllers/HomeController.php
namespace App\Controllers;

use Lighthouse\Controller;

class HomeController extends Controller
{
    public function index()
    {
        return $this->view('home');
    }
}

views/

PHP template files.

php
// views/home.php
<?php $view->extends('layouts.main'); ?>

<?php $view->section('content'); ?>
<h1>Welcome!</h1>
<?php $view->endSection(); ?>

tests/

PHPUnit tests.

php
// tests/ExampleTest.php
public function test_homepage_works(): void
{
    // ...
}

Released under the MIT License.