Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wilfredpine/confired
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.
https://github.com/wilfredpine/confired
framework model-view-controller mvc mvc-architecture mvc-framework oop php
Last synced: 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/wilfredpine/confired
- Owner: wilfredpine
- License: gpl-3.0
- Created: 2021-02-15T06:13:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-13T08:51:38.000Z (2 months ago)
- Last Synced: 2024-11-13T09:32:50.672Z (2 months ago)
- Topics: framework, model-view-controller, mvc, mvc-architecture, mvc-framework, oop, php
- Language: PHP
- Homepage: https://confired.com
- Size: 55.7 KB
- Stars: 9
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [ConfiRed](https://confired.com) (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
```php
define('ENVIRONMENT', 'development');
//define('ENVIRONMENT', 'production');
define('BASE_URL', 'https://confired.com/');
//define('BASE_URL', 'http://localhost/confired/');
```* db.php - database configuration
```php
define('DBHOST','localhost');
define('DBNAME','confired');
define('DBUSER','root');
define('DBPASS','');
define('CHARSET','utf8');
define('DBPORT',':3306');
```* map.php - set routing configuration
```php
// 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
```php
// 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
```php
$this->callLibraries(['form']);
$this->callLibraries(['session']);
```
* use Object```php
$this->form = new Form;
$this->session = new Session;
```### methods
-POST
* use Object
```php
$this->form->post('username');
$this->session->push(['username'=>'Juan']);
```
or* use Static functions associated with the class
```php
Form::post('username');
Session::push(['username'=>'Juan']);
```* Passing data with model
```php
$data['users'] = $this->access_model->users();
```* Clean Data before post if not using Form Library
```php
cleanData($_POST['username']);
```* CSRF
```php
/* generate */
echo CSRFToken();
/* validate */
if(CSRFProtect(cleanData($_POST['token'])))
{
}
```* View
```php
$this->preview('home',$data);
```* Header Location / redirect
```php
transmit('Access');
```## System Model
### visit: [phpdelusions](https://phpdelusions.net/pdo)
```php
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
```php
echo Sanitize($data['column']);
```* External CSS / JS
```php
// require style.css
callCSS(array('style'));
// require custom.js
callJS(array('custom'));
```* Active page
```php
// active('Home');
```
* Alerts / Notification
```php
notify(); // suit/glob/Notification.php
```
## Create Global functions
* suit/glob/filename.php
```php
// set the functions on startup
// suit/dev/startup.php
define('FUNCTIONS', array('setting','notification','filename'));
```
## Session
```php
Session::pull('username')
Session::push(['name'=>'data','username'=>$username])
```
## License
[GNU](https://github.com/wilfredpine/confired/blob/main/LICENSE)