lighthouse / skeleton
Lighthouse Framework Application Skeleton
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/lighthouse/skeleton
Requires
- php: ^8.2
- lighthouse/framework: ^0.1
Requires (Dev)
- phpunit/phpunit: ^11.0
README
A fresh Lighthouse Framework application.
Installation
composer create-project lighthouse/skeleton my-app
cd my-app
Development Server
Start the built-in PHP server:
composer start
Then visit http://localhost:8000
Project Structure
my-app/
├── config/
│ └── app.php # Application configuration
├── public/
│ ├── index.php # Entry point
│ └── .htaccess # Apache rewrite rules
├── routes/
│ └── web.php # Route definitions
├── src/
│ └── Controllers/ # Your controllers
├── views/
│ ├── layouts/ # Layout templates
│ └── *.php # View templates
├── tests/ # Test files
├── .env.example # Environment template
└── composer.json
Configuration
Copy .env.example to .env and adjust settings:
cp .env.example .env
Or configure directly in config/app.php.
Creating Routes
Edit routes/web.php:
// Closure route $app->get('/hello', function () { return 'Hello, World!'; }); // Controller route $app->get('/users', [UserController::class, 'index']); // Route with parameter $app->get('/users/{id}', [UserController::class, 'show']); // Route group $app->group('/api', function ($router) { $router->get('/users', [ApiUserController::class, 'index']); }); // Named route $app->get('/profile', [ProfileController::class, 'show'])->name('profile');
Creating Controllers
Create a new controller in src/Controllers/:
<?php namespace App\Controllers; use Lighthouse\Controller; use Psr\Http\Message\ResponseInterface; class UserController extends Controller { public function index(): ResponseInterface { return $this->view('users.index', [ 'users' => $this->getUsers(), ]); } public function show(string $id): ResponseInterface { return $this->json([ 'id' => $id, 'name' => 'John Doe', ]); } }
Creating Views
Create views in views/:
views/users/index.php:
<?php $view->extends('layouts.main'); ?> <?php $view->section('content'); ?> <h1>Users</h1> <ul> <?php foreach ($users as $user): ?> <li><?= $view->e($user['name']) ?></li> <?php endforeach; ?> </ul> <?php $view->endSection(); ?>
Testing
composer test
Deployment
For production:
- Set
APP_DEBUG=falsein your environment - Point your web server to the
public/directory - Ensure all requests are routed to
public/index.php
Nginx Configuration
server { listen 80; server_name example.com; root /var/www/my-app/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } }
Learn More
License
MIT