aymdev/phunder-skeleton

A predefined architecture to use the Phunder framework

v1.1.2 2018-12-04 13:32 UTC

README

A predefined architecture to use the Phunder framework.
Phunder is a lightweight MVC framework including a router and a templating engine.

PHP 7.1+ required

Installation

With composer:

composer create-project aymdev/phunder-skeleton

Getting Started

After installing, you can reach the demo page : your_phunder_path/ or your_phunder_path/home.

Architecture

Your PHP classes must be located in the /src/ directory and follow the PSR-4 standard.
Config file should be located in the /config/ directory and included at the end of /config/bootstrap.php.
Every Front-End asset file must be located in /public/ directory without mandatory structure (see URL management for linking).

MVC

Your controller classes must extend Phunder\Core\Controller\Controller.

For any data that you need into a template there is the Controller::set() method:

self::set('var_name', $obj->method());
self::set('key', 'value');

Templates

Phunder uses EKF - Element-Key-Flag as its core templating engine.
Create your templates in /templates/ (change it by redefining PHUNDER_TEMPLATE_DIRECTORY in a /config/phunder_config.php file).

To render a template, call your controller's render method with the template path relative to the templates directory:

self::render('home.html');

Take a minute to learn EKF syntax

URL management

Phunder uses PPRR - Pure PHP Regex Router as its core router.
Simply define routes as partial regular expressions (see above link) in /public/index.php.

URL are rewritten by the .htaccess file using mod_rewrite. Every request will be sent to public/index.php. Your assets files (stylesheets, scripts, images ...) links must be prefixed with _front/. Example:

<link rel="stylesheet" href="_front/css/styling.css">

Demo

There is a demo route to let you try it. You might be interested in looking at these files :

Phunder/
├── src/
│   └── Controller/
│       └── Home.php
├── templates/
│   └── home.html
└── public/
    └── index.php