diff --git a/README.md b/README.md index c6f8da9..7512a53 100755 --- a/README.md +++ b/README.md @@ -4,11 +4,13 @@ A tiny PHP starter project for small websites and personal projects. The goal is simple: -- Clone -- Change git remote -- Start building +* Clone +* Change git remote +* Start building No framework. +No Composer. +No external dependencies. No ORM. No dependency injection. No magic. @@ -19,13 +21,28 @@ 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 +* 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: + +```bash +php -m +``` --- @@ -33,7 +50,6 @@ Just PHP. ```text config/ -├── app.php ├── database.php └── routes.php @@ -55,12 +71,17 @@ src/ storage/ └── database.sqlite + +index.php +server.sh ``` --- ## Running +Start the development server: + ```bash ./server.sh ``` @@ -113,28 +134,90 @@ src/views/pages/ --- -## Pages +## Adding A New Page -Example page: +### 1. Create the page + +Create: + +```text +src/views/pages/contact.php +``` + +Example: ```php - 'Contact']); ?> -partial('head', [ - 'title' => 'Home', -]); +

Contact

-?> - -

Home

- -

Hello world.

+

Get in touch.

[ + '/contact' => 'contact.php', +], +``` + +Visit: + +```text +http://localhost:3333/contact +``` + +--- + +## Adding An API Endpoint + +### 1. Create the endpoint + +Create: + +```text +src/api/contact.php +``` + +Example: + +```php + true]); +``` + +### 2. Add the route + +```php +'GET' => [ + '/api/contact' => 'api/contact.php', +], +``` + +Visit: + +```text +http://localhost:8000/api/contact +``` + --- ## SQLite @@ -150,9 +233,7 @@ Usage: ```php $db = db(); -$rows = $db->query( - 'SELECT * FROM users' -)->fetchAll(); +$rows = $db->query('SELECT * FROM users')->fetchAll(); ``` --- @@ -171,6 +252,16 @@ 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 \ No newline at end of file +MIT