A minimal PHP project to demonstrate how simple and clean plain PHP can be — no frameworks, just includes and good structure.
This project shows how to build a maintainable, structured PHP site using:
include/requirefor layout and componentsconfig.phpfor site data and settings- Basic routing with
index.php?page=...or just?page=... - Reusable components like navbar and footer
simple-php-web/
├── index.php
├── config.php
├── routes.php
├── components/
│ ├── layout.php
│ ├── navbar.php
│ ├── footer.php
│ ├── alert.php
├── views/
│ ├── home.php
│ ├── pricing.php
│ ├── about.php
│ ├── contact.php
│ ├── faq.php
│ └── 404.php
└── css/
└── style.css
<?php
return [
'site_name' => 'simple-php-web',
'pricings' => [
['title' => 'Basic', 'price' => '$10/mo'],
['title' => 'Pro', 'price' => '$20/mo'],
['title' => 'Enterprise', 'price' => 'Contact us'],
],
'faqs' => [
['q' => 'Is this Laravel?', 'a' => 'No, just PHP.'],
['q' => 'Can I use this to learn?', 'a' => 'Absolutely.'],
],
];
<?php
return [
'home' => [
'view' => 'views/home.php',
'title' => 'Home'
],
'pricing' => [
'view' => 'views/pricing.php',
'title' => 'Pricing'
],
'faq' => [
'view' => 'views/faq.php',
'title' => 'FAQ'
],
'stuff' => [
'view' => 'test/a/b/c.php',
'title' => 'Example view route'
]
];
- Clone the repo
- Run PHP’s built-in server:
php -S localhost:8000 - Visit
http://localhost:8000in your browser
- Dynamic routing with
?page= - Automatic 404 fallback
- Config-driven data (pricing, FAQs)
- Reusable layout and components
- Alerts via config or query string
- Active nav link highlighting
Alerts are shown using the components/alert.php file. You can add static alerts via config.php, or show alerts dynamically via URL:
Append ?alert_type=success&alert_message=Hello+world! to any page.
successinfowarningerrorordanger
you can add more by creating styles for it instyle.css.
?page=home&alert_type=info&alert_message=Welcome+to+the+site!?page=pricing&alert_type=success&alert_message=Great+choice!?page=faq&alert_type=error&alert_message=Something+went+wrong.
MIT – Use this for learning or small projects. Contributions welcome!