Skip to content

A light and basic PHP MVC Framework. It was created to examine the structure of an MVC Framework and how it works. It uses static methods to implement Libraries or Helpers better, clear, and easy management. In some PHP versions, a static method is slower than non-static methods. You can also use object-oriented approach.

License

Notifications You must be signed in to change notification settings

wilfredpine/confired

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConfiRed (light & basic PHP MVC Framework)

A light and basic PHP MVC Framework. It was created to examine the structure of an MVC Framework and how it works. It uses static methods to implement Libraries or Helpers better, clear, and easy management. In some PHP versions, a static method is slower than non-static methods. You can also use object-oriented approach.

Developed by Wilfred V. Pine © 2020

Version: 1.4.0

System Configuration

suit/dev

  • config.php - configure environment, base_url
define('ENVIRONMENT', 'development');
//define('ENVIRONMENT', 'production');
define('BASE_URL', 'https://confired.com/');
//define('BASE_URL', 'http://localhost/confired/');
  • db.php - database configuration
define('DBHOST','localhost');
define('DBNAME','confired');
define('DBUSER','root');
define('DBPASS','');
define('CHARSET','utf8');
define('DBPORT',':3306');
  • map.php - set routing configuration
// Default controller to load
define('DEFAULT_CONTROLLER', 'Home');
define('DEFAULT_METHOD', 'index');

// roouting
Map::site(['Login'=>'Access']);
Map::site(['Logging-in'=>'Access/signing_in']);
Map::site(['Category-list/@any'=>'Category/index/$1']);
  • startup.php - load services on startup
// Models
define('MODELS', array('access'));
// Helpers
define('HELPERS', array('page_url','session'));
// Addons
define('ADD_ON', array());
// Libraries
define('LIBRARIES', array('protection','form'));
// Function
define('FUNCTIONS', array('setting','notification','filename'));

System Controller

contructor

  • if not added to startup
$this->callLibraries(['form']);
$this->callLibraries(['session']);
  • use Object
$this->form = new Form;
$this->session = new Session;

methods

-POST

  • use Object
$this->form->post('username');
$this->session->push(['username'=>'Juan']);

or

  • use Static functions associated with the class
Form::post('username');
Session::push(['username'=>'Juan']);
  • Passing data with model
$data['users'] = $this->access_model->users();
  • Clean Data before post if not using Form Library
cleanData($_POST['username']);
  • CSRF
/* generate */
echo CSRFToken();
/* validate */
if(CSRFProtect(cleanData($_POST['token'])))
{
    
}
  • View
$this->preview('home',$data);
  • Header Location / redirect
transmit('Access');

System Model

public function users($id){
    $sql = "SELECT * FROM users WHERE id = :id LIMIT 1";
    $query = $this->db->prepare($sql);
    $parameters = array(':id' => $id);
    $query->execute($parameters);
    return ($query->rowcount() ? $query->fetch() : false);
}

System View

  • Sanitize Data
echo Sanitize($data['column']);
  • External CSS / JS
// require style.css
callCSS(array('style'));
// require custom.js
callJS(array('custom'));
  • Active page
// active('Home');
<li class="<?php active('Home'); ?>"><a href="">Home</a></li>
  • Alerts / Notification
notify(); // suit/glob/Notification.php

Create Global functions

  • suit/glob/filename.php
// set the functions on startup
// suit/dev/startup.php
define('FUNCTIONS', array('setting','notification','filename'));

Session

Session::pull('username')
Session::push(['name'=>'data','username'=>$username])

License

GNU

About

A light and basic PHP MVC Framework. It was created to examine the structure of an MVC Framework and how it works. It uses static methods to implement Libraries or Helpers better, clear, and easy management. In some PHP versions, a static method is slower than non-static methods. You can also use object-oriented approach.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published