d71d0f12bd701abdf9c1e266f7ba04a4858f4259
miniPHP
A tiny PHP starter project for small websites and personal projects.
The goal is simple:
- Clone
- Change git remote
- Start building
No framework. No ORM. No dependency injection. No magic.
Just PHP.
Features
- Simple config-based router
- Page and API endpoints
- SQLite support via PDO
- Shared partials
- Secure path traversal protection
- Helper functions
- Development server script
Project Structure
config/
├── app.php
├── database.php
└── routes.php
public/
├── css/
│ └── app.css
└── js/
└── app.js
src/
├── api/
├── views/
│ ├── pages/
│ └── partials/
├── bootstrap.php
├── database.php
├── helpers.php
└── router.php
storage/
└── database.sqlite
Running
./server.sh
Default URL:
http://127.0.0.1:3333
Routes
Routes are defined in:
config/routes.php
Example:
return [
'GET' => [
'/' => 'home.php',
'/about' => 'about.php',
'/api/test' => 'api/example.php',
],
];
Routes beginning with:
api/
are loaded from:
src/api/
Everything else is loaded from:
src/views/pages/
Pages
Example page:
<?php
partial('head', [
'title' => 'Home',
]);
?>
<h1>Home</h1>
<p>Hello world.</p>
<?php
partial('footer');
SQLite
Database configuration:
config/database.php
Usage:
$db = db();
$rows = $db->query(
'SELECT * FROM users'
)->fetchAll();
Helpers
Available helpers:
escape_string()
debug()
debugx()
get_config()
partial()
License
MIT
Languages
PHP
84.4%
Shell
13.7%
CSS
0.9%
Hack
0.6%
JavaScript
0.4%