A lightweight, modular PHP framework that pairs PHP 8.4, Smarty 5.6, and MySQL 8.0 (PDO).
Clean routing, controller → template flow (layout + content slot), Bootstrap 5 UI, and a Leaflet + OpenStreetMap demo to get you started fast.
- Front controller with clean URL routing
- Controllers + Templates with a simple layout (
Home.tpl) and a content slot - PDO MySQL connection via
.env(usingvlucas/phpdotenv) - Bootstrap 5 + Font Awesome skeleton (local assets under
/public/assets) - Leaflet + OpenStreetMap sample page (
/map/) - PSR-4 autoload ready (Composer)
project-root/
app/
bootstrap.php
Router.php
Controllers/
LandingController.php
MapController.php
classes/ # optional custom classes (PSR-4 or custom autoloader)
templates/
Home.tpl # layout (includes Header.tpl, Footer.tpl optionally)
Header.tpl
Footer.tpl
Landing/
Landing.tpl # one-page landing content
Map/
Map.tpl # Leaflet + OSM demo
public/
.htaccess
index.php # front controller (docroot points here)
assets/
css/, js/, images/, fontawesome/, leaflet/
vendor/
composer.json
.env.example
- PHP 8.4
- MySQL 8.0
- Composer
- Web server pointing the document root to
public/
composer install
cp .env.example .env
# edit .env with your DB credentials.env example:
MYSQL_HOST=127.0.0.1
MYSQL_DBNAME=easyframework
MYSQL_USER=root
MYSQL_PASS=secret
MYSQL_PORT=3306Point your vhost docroot to project-root/public.
Apache example (public/.htaccess already included):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(.*)$ index.php [QSA,L]- Open
http://your-host/→ One-Page Landing - Open
http://your-host/map/→ Leaflet + OSM demo
- Routing:
public/index.php→app/Router.phpparses the path. - Controllers: Slug
mapbecomesApp\Controllers\MapController.
Controller renders a content template (Map/Map.tpl) and injects it into the layout (Home.tpl) via a{$content}slot. - Templates:
Header.tplandFooter.tplcan be swapped per page via assigned variables.
Composer scripts (suggested):
{
"scripts": {
"post-install-cmd": ["@dump", "@setup-dirs"],
"post-update-cmd": ["@dump", "@setup-dirs"],
"dump": "composer dump-autoload -o",
"setup-dirs": [
"php -r \"@mkdir('templates_c', 0777, true); @mkdir('cache', 0777, true); echo 'templates_c & cache ready'.PHP_EOL;\""
]
}
}PSR-4 autoload (composer.json):
{
"autoload": {
"psr-4": { "App\\": "app/" }
}
}Then:
composer dump-autoload -oA minimal Leaflet map is provided in templates/Map/Map.tpl.
You can switch to locally hosted Leaflet assets under /public/assets/leaflet if preferred.
- Keep
app/,templates/, and.envoutside of the web root. Onlypublic/is web-accessible. - Disable multi-statements for PDO (
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false). - Ensure
templates_c/andcache/are writable by the web server user.
MIT — see LICENSE.
GitHub doesn’t auto-switch languages for README.md, but you can:
- Provide separate files like
README.hu.md,README.en.mdand link them at the top ofREADME.md. - Or use a
/docsfolder per language. - Or publish a GitHub Pages site with language selector.
Example header in README.md:
**Read this in other languages**: [Magyar](README.hu.md) • [English](README.md)