A tiny, educational PHP framework used for learning how common framework pieces fit together: a service container, HTTP kernel, routing, a small ActiveRecord-style ORM, migrations, and a minimal view engine.
- PHP 8.0+ with PDO and SQLite support
- Composer (optional for autoloading and installing dependencies)
- Clone the repo:
git clone <repo-url> mini
cd mini- Install dependencies (if you add any via Composer):
composer install- Ensure the database file exists (project root):
touch database.sqlite- Run migrations:
php mini migrateThis will create the users, posts, and migrations tables.
Start the built-in PHP server (recommended for local development):
php mini serve
# or use php directly:
php -S 127.0.0.1:9003 -t public public/index.phpOpen http://127.0.0.1:9003 in your browser.
If you'd like a quick user to test User::find(1), insert one with sqlite3:
sqlite3 database.sqlite "INSERT INTO users (name, email) VALUES ('Elliot Anderson', 'elliot@example.com');"
sqlite3 database.sqlite "SELECT id, name, email FROM users;"If you see database is locked errors, close any DB browsers (e.g. DB Browser for SQLite) that may be holding the file open.
- Add a route in
routes/web.php:
use Framework\Routing\Router;
use Framework\Http\Response;
use App\Models\User;
return function (Router $router): void {
$router->get('/hello', function () {
return new Response('Hello from mini');
});
$router->get('/user-test', function () {
$user = User::find(1);
return new Response($user ? "User: {$user->getAttribute('name')}" : 'No user');
});
};- Create a controller with the CLI (convenience):
php mini make:controller UserControllerThen edit app/Http/Controllers/UserController.php and register routes pointing to UserController@method.
- Create a migration:
php mini make:migration add_profile_to_usersEdit the generated file in database/migrations/ and then run php mini migrate again.
- Views live in
resources/viewsand are compiled tostorage/views. - Use
View::make('view.name', ['var' => 'value'])to render templates.
- The small docs site is at
docs/index.html. You can preview it locally with a static server:
# from project root
python3 -m http.server 8000
# then open http://localhost:8000/docs/index.htmlI added a small scrollspy and syntax highlighting (Highlight.js) to make the docs easier to navigate.
- "database is locked": close other applications holding the SQLite file, or kill the process.
- If migrations fail, check the SQL in
database/migrations/*.phpand run them manually viasqlite3 database.sqlitefor debugging.
This project is intentionally tiny and educational. Feel free to open issues or PRs with improvements or features you want to try.
If you'd like, I can also add a README badge, or generate a CONTRIBUTING.md with development guidelines.