Update README.md

This commit is contained in:
jasonhilder
2026-05-29 10:34:52 +02:00
parent 211c9d7d96
commit d71d0f12bd
+174 -1
View File
@@ -1,3 +1,176 @@
# miniPHP
A simple php skeleton to making small to medium scale websites/webapps.
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
```text
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
```bash
./server.sh
```
Default URL:
```text
http://127.0.0.1:3333
```
---
## Routes
Routes are defined in:
```php
config/routes.php
```
Example:
```php
return [
'GET' => [
'/' => 'home.php',
'/about' => 'about.php',
'/api/test' => 'api/example.php',
],
];
```
Routes beginning with:
```text
api/
```
are loaded from:
```text
src/api/
```
Everything else is loaded from:
```text
src/views/pages/
```
---
## Pages
Example page:
```php
<?php
partial('head', [
'title' => 'Home',
]);
?>
<h1>Home</h1>
<p>Hello world.</p>
<?php
partial('footer');
```
---
## SQLite
Database configuration:
```php
config/database.php
```
Usage:
```php
$db = db();
$rows = $db->query(
'SELECT * FROM users'
)->fetchAll();
```
---
## Helpers
Available helpers:
```php
escape_string()
debug()
debugx()
get_config()
partial()
```
---
## License
MIT