2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00
2026-02-14 23:00:52 +00:00

Simple Framework

A lightweight PHP framework with clean routing and template management.

Features

  • Simple Routing: Clean URLs through index.php (e.g., /index.php/about)
  • Template System: Organized template files with reusable header/footer
  • Output Buffering: Templates can set variables that are used in header/footer
  • Configuration Management: Centralized constants in assets/config.php
  • No Dependencies: Pure PHP, no external libraries required

Structure

/
├── assets/
│   ├── config.php          # Site configuration and constants
│   ├── css/
│   │   └── style.css       # Main stylesheet
│   └── js/
│       └── main.js         # Main JavaScript
├── includes/
│   ├── header.php          # Site header
│   └── footer.php          # Site footer
├── templates/
│   ├── home.php            # Home page template
│   ├── about.php           # About page template
│   └── contact.php         # Contact page template
├── index.php               # Bootstrap/Router
└── README.md

How It Works

  1. index.php receives all requests and parses the URL
  2. It determines which template to load from PAGE_TEMPLATES in config
  3. The template file is loaded with ob_start() to buffer output
  4. Templates can set variables like $pageTitle, $pageDescription, $additionalHead, etc.
  5. The header is rendered (with access to template variables)
  6. The buffered template content is output
  7. The footer is rendered

Configuration

Edit assets/config.php to customize:

  • SITE_NAME - Your site name
  • SITE_URL - Your site URL
  • PAGE_TEMPLATES - Add/remove pages and their settings

Adding New Pages

  1. Add a new entry to PAGE_TEMPLATES in assets/config.php:
'services' => [
    'file' => 'services.php',
    'title' => 'Services'
]
  1. Create the template file in templates/services.php
  2. The page will automatically appear in the navigation

Template Variables

Templates can set these variables to customize the output:

  • $pageTitle - Page title (appears in <title> tag)
  • $pageDescription - Meta description
  • $bodyClass - CSS class for <body> tag
  • $additionalHead - Extra HTML for <head> section
  • $footerExtra - Extra content in the footer

Example Template

<?php
$pageTitle = 'My Page';
$pageDescription = 'This is my page description';
$bodyClass = 'my-custom-class';
?>

<section>
    <h1>My Page Content</h1>
    <p>This content will be wrapped by header and footer.</p>
</section>

Server Configuration

Apache

Enable mod_rewrite and use this .htaccess for cleaner URLs (optional):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

PHP Built-in Server

For development:

php -S localhost:8000

Then visit: http://localhost:8000/index.php/about

License

Free to use for any purpose.

Description
No description provided
Readme 29 KiB
Languages
PHP 41%
CSS 30.1%
JavaScript 12.2%
Hack 11.8%
Dockerfile 4.9%