2026-05-29 10:42:52 +02:00
2026-05-29 10:42:14 +02:00
2026-05-29 10:32:47 +02:00
2026-05-29 10:42:52 +02:00
2026-05-29 09:28:30 +02:00

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 Composer. No external dependencies. No ORM. No dependency injection. No magic.

Just PHP.


Features

  • Zero dependencies
  • No Composer required
  • Simple config-based router
  • Page and API endpoints
  • SQLite support via PDO
  • Shared partials
  • Secure path traversal protection
  • Helper functions
  • Development server script

Requirements

  • PHP 8.1+
  • SQLite extension (optional)

Check installed extensions:

php -m

Project Structure

config/
├── 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

index.php
server.sh

Running

Start the development server:

./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/

Adding A New Page

1. Create the page

Create:

src/views/pages/contact.php

Example:

<?php partial('head', ['title' => 'Contact']); ?>

<h1>Contact</h1>

<p>Get in touch.</p>

<?php

partial('footer');

2. Add the route

Edit:

config/routes.php

Add:

'GET' => [
    '/contact' => 'contact.php',
],

Visit:

http://localhost:3333/contact

Adding An API Endpoint

1. Create the endpoint

Create:

src/api/contact.php

Example:

<?php

declare(strict_types=1);

header('Content-Type: application/json');

echo json_encode(['success' => true]);

2. Add the route

'GET' => [
    '/api/contact' => 'api/contact.php',
],

Visit:

http://localhost:8000/api/contact

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()

Philosophy

miniPHP intentionally avoids framework features.

If a feature can be implemented with plain PHP and a few lines of code, prefer that approach.

The goal is to remain small, understandable, and easy to clone for future projects.


License

MIT

S
Description
No description provided
Readme MIT 56 KiB
Languages
PHP 84.4%
Shell 13.7%
CSS 0.9%
Hack 0.6%
JavaScript 0.4%