Skip to content

hunnomad/easyFramework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ EasyFramework

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.

PHP Smarty MySQL License

✨ Features

  • Front controller with clean URL routing
  • Controllers + Templates with a simple layout (Home.tpl) and a content slot
  • PDO MySQL connection via .env (using vlucas/phpdotenv)
  • Bootstrap 5 + Font Awesome skeleton (local assets under /public/assets)
  • Leaflet + OpenStreetMap sample page (/map/)
  • PSR-4 autoload ready (Composer)

📁 Project Structure

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

🚀 Getting Started

1) Requirements

  • PHP 8.4
  • MySQL 8.0
  • Composer
  • Web server pointing the document root to public/

2) Install

composer install
cp .env.example .env
# edit .env with your DB credentials

3) Environment

.env example:

MYSQL_HOST=127.0.0.1
MYSQL_DBNAME=easyframework
MYSQL_USER=root
MYSQL_PASS=secret
MYSQL_PORT=3306

4) Web Server

Point 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]

5) Run

  • Open http://your-host/ → One-Page Landing
  • Open http://your-host/map/ → Leaflet + OSM demo

🧩 How It Works

  • Routing: public/index.phpapp/Router.php parses the path.
  • Controllers: Slug map becomes App\Controllers\MapController.
    Controller renders a content template (Map/Map.tpl) and injects it into the layout (Home.tpl) via a {$content} slot.
  • Templates: Header.tpl and Footer.tpl can be swapped per page via assigned variables.

🧰 Development

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 -o

🗺️ Demo: Leaflet + OpenStreetMap

A minimal Leaflet map is provided in templates/Map/Map.tpl.
You can switch to locally hosted Leaflet assets under /public/assets/leaflet if preferred.

🔐 Security Notes

  • Keep app/, templates/, and .env outside of the web root. Only public/ is web-accessible.
  • Disable multi-statements for PDO (PDO::MYSQL_ATTR_MULTI_STATEMENTS => false).
  • Ensure templates_c/ and cache/ are writable by the web server user.

📜 License

MIT — see LICENSE.

🌍 Multi-language README

GitHub doesn’t auto-switch languages for README.md, but you can:

  • Provide separate files like README.hu.md, README.en.md and link them at the top of README.md.
  • Or use a /docs folder 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)

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages