Sunhill Framework is a simple, fast, and powerful PHP App Development Framework

Overview

PHP MVC App Development Framework

Sunhill Framework is a simple, fast, and powerful PHP App Development Framework that enables you to develop more modern applications by using MVC (Model - View - Controller) pattern.


Table of Contents

Installation

  1. Download all files and directories (except Examples directory).
  2. Change the htaccess.txt file's name to the .htaccess (important)
  3. Open System/Config.php and edit your database, cache, and system settings.
  4. Create your controllers, views and models.

See below for more details.

Main Structure

root
├── App
│   ├── Controllers
│   │   ├── Error.php
│   │   └── Home.php
│   ├── Models
│   │   ├── Error.php
│   │   └── Home.php
│   └── Views
│       ├── Error.php
│       └── Home.php
├── Core
│   ├── App.php
│   ├── Controller.php
│   ├── Model.php
│   └── View.php
├── Public
│   ├── cache
│   ├── css
│   ├── img
│   └── js
├── System
│   ├── Config.php
│   ├── SunCache.php
│   ├── SunDB.php
│   └── SunSitemap.php
├── .htaccess
├── index.php
└── init.php

Directories

App/Controller: Create your custom controllers in this folder.

App/Models: Create your custom models in this folder.

App/Views: Create your custom views in this folder.

Core: This folder contains the main app, model, view, and controller files. All custom model, view, and controller files inherit from these. Don't make changes to these files if don't need really.

Public: Upload all your custom files (css, js, img, bootstrap, etc.) into this folder. Your custom views will use these files.

System: This folder contains system classes and config files. Make your changes only in the config file.

Configuration

Open System/Config.php file and make your changes.

Database Settings:

define ('DB_HOST', 'localhost'); // database host
define ('DB_PORT', '3306'); // database port
define ('DB_DBNAME', ''); // database name
define ('DB_USERNAME', ''); // database username
define ('DB_PASSWORD', ''); // database password

Cache Settings:

$cacheConfig = [
    'cacheDir'      => '/../Public/cache', // cache folder path
    'fileExtension' => 'html', // cache file extension
    'storageTime'   => 24*60*60, // storage time (seconds)
    'contentMinify' => true, // content minification
    'showTime'      => true, // show page load time
    'sefUrl'        => true // website sef url status
];

System Settings:

define ('SYS_PHPERR', true); // php errors (show or hide, true / false)
define ('SYS_SYSERR', false); // system errors (shor or hide, true / false)
define ('SYS_PGCACHE', false); // page caching (true / false)
define ('SYS_CHEXCLUDE', []); // excluded pages for page caching (array)
define ('SYS_HOMEPAGE', 'home'); // home page (index, home, main, etc.)
define ('SYS_ERRPAGE', 'error'); // error page (if requested page does not exist, redirect to this page)

URL Scheme Examples

Sample URL:

https://www.web_address.com/[controller_name]/[method_name]/[parameters]

Call a page (controller):

https://www.sunhillint.com/user

This address will call the User controller.

Call a page (controller) with action (method):

https://www.sunhillint.com/user/list

This address will call the User controller and execute list method.

Call a page (controller) with action (method) and parameters:

https://www.sunhillint.com/user/update/3

This address will call the User controller and execute update method with 3 parameter.

Controllers

Controllers respond to user actions (submitting forms, clicking links, etc.). Controllers are classes that extend the Core\Controller class.

Controllers are stored in the App/Controllers folder. A sample Home and Error controllers are included. Controller classes need to be in the App/Controllers namespace. You can add subdirectories to organize your controllers, so when adding a route for these controllers you need to specify the namespace.

Sample controller file content (without database access, static page):

public function show() {
    require_once ($this->view); // include view file (with $result content)
}

Sample controller file content (with database access, dynamic page):

public function show() {
    if (!empty($this->model)) { // if this page needs database
        $result = ($this->model)->show(); // call model class' show method
    }
    require_once ($this->view); // include view file (with $result content)
}

Controller classes contain methods that are the actions. To create an action, add the method name in the controller and use this into the URL (route parameters).

Sample URL:

https://www.web_address.com/[controller_name]

All pages must have a controller file and show method must be in it.

Views

Views are used to display information. View files go in the App/Views folder. No database access or anything like that should occur in a view file.

Views extend the Core\View class and if your view (page) needs database access, your values will be forwarded from the controller file.

Sample view file content for multiple records (inside html tags):

foreach ($result as $row) {
    echo "...";
}

or (for one record):

echo $result[0]['content'];

All pages must have a View file.

Models

Models are used to get and store data in your application. They know nothing about how this data will be presented in the views. Models extend the Core\Model class and use PDO to access the database (including SunDB class). They're stored in the App/Models folder.

All pages must have a model file (even if it's empty) and show method must be in it.

Using SunDB PDO Class through main model:

$result = $this->query('SELECT * FROM table_name'); // send query to the main model
return $result; // return the result to the controller

Using SunDB PDO Class directly:

$result = ($this->pdo)->select('table_name')
                      ->run(); // select all records from the table
return $result; // return the result to the controller

Please see SunDB PDO Class for detailed usage.

Page Caching

The framework includes a special page caching system (SunCache class).

Caching system can be activate/deactivate in System/Config.php file:

define ('SYS_PGCACHE', true); // page caching (true / false)

Excluded pages can be defined in System/Config.php file:

define ('SYS_CHEXCLUDE', ['home', 'error']); // excluded pages for page caching (array)

Cache settings can be changed in System/Config.php file:

$cacheConfig = [
    'cacheDir'      => '/../Public/cache', // cache folder path
    'fileExtension' => 'html', // cache file extension
    'storageTime'   => 24*60*60, // storage time (seconds)
    'contentMinify' => true, // content minification
    'showTime'      => true, // show page load time
    'sefUrl'        => true // website sef url status
];

Please see SunCache Class for detailed usage.

You might also like...
a framework for WebDevelop based on the mvc structure. The name of this project for Fun because everyone can use it. Completely simple and powerful structure for all your projects

A_A (-.-) ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ |-| █▄─▄▄─█▄─██─▄█─▄▄▄▄█─▄▄▄▄█▄─█─▄█─▄▄▄─██▀▄─██─▄

 Symplify - Making Everyday PHP Development Simple
Symplify - Making Everyday PHP Development Simple

Symplify - Making Everyday PHP Development Simple In this monorepo you'll find PHP packages that help you with: your first coding standard maintenance

Hamtaro - the new web framework for front-end / back-end development using Php and Javascript.

Hamtaro framework About Technologies Controllers Components Commands Front-end development Getting Started About Hamtaro is the new web framework for

PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.
PhpBoot is an easy and powerful PHP framework for building RESTful/Microservices APIs.

🚀 tiny & fast PHP framework for building Microservices/RESTful APIs, with useful features: IOC, Hook, ORM, RPC, Swagger, Annotation, Parameters binding, Validation, etc.

Yii 2: The Fast, Secure and Professional PHP Framework
Yii 2: The Fast, Secure and Professional PHP Framework

Yii 2 is a modern framework designed to be a solid foundation for your PHP application. It is fast, secure and efficient and works right out of the bo

Fast and easy PHP framework

Español | English Fácil, rápido y en español (Or should I say fast and easy?) Bienvenidos a KumbiaPHP Framework Versión 1 Manual en construcción de la

Flare is a PHP full-stack web framework that is light, fast, flexible, and secure.
Flare is a PHP full-stack web framework that is light, fast, flexible, and secure.

Flare framework is a PHP full-stack web framework that is simple ,powerful , fast , flexible, and secure with long-term support.

Fast and easy PHP framework

Español | English Fácil, rápido y en español (Or should I say fast and easy?) Bienvenidos a KumbiaPHP Framework Versión 1 Manual en construcción de la

CodeIgniter - a PHP full-stack web framework that is light, fast, flexible and secure

CodeIgniter 4 Development What is CodeIgniter? CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. More informatio

Owner
Mehmet Selcuk Batal
Chairman - Instructor - Author
Mehmet Selcuk Batal
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
QPM, the process management framework in PHP, the efficient toolkit for CLI development. QPM provides basic daemon functions and supervision mechanisms to simplify multi-process app dev.

QPM QPM全名是 Quick(or Q's) Process Management Framework for PHP. PHP 是强大的web开发语言,以至于大家常常忘记PHP 可以用来开发健壮的命令行(CLI)程序以至于daemon程序。 而编写daemon程序免不了与各种进程管理打交道。Q

Comos 75 Dec 21, 2021
Easy to use, fast extendable small PHP Framework, like the one you ever missed. The skeleton-APP

About Tufu-Framework Easy to use, fast extendable PHP Framework, like the one you ever missed. Features included such as: Twig and extensions. Fast ro

Giacomo Barbalinardo 0 Jul 2, 2022
CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework

CleverStyle Framework is simple, scalable, fast and secure full-stack PHP framework. It is free, Open Source and is distributed under Free Public Lice

Nazar Mokrynskyi 150 Apr 12, 2022
Framework X is a simple and fast micro framework based on PHP

Framework X is a simple and fast micro framework based on PHP. I've created a simple CRUD application to understand how it works. I used twig and I created a custom middleware to handle PUT, DELETE methods.

Mahmut Bayri 6 Oct 14, 2022
Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily.

Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily. Leaf introduces a cleaner and much simpler structure to the PHP language while maintaining it's flexibility. With a simple structure and a shallow learning curve, it's an excellent way to rapidly build powerful and high performant web apps and APIs.

Leaf Framework 706 Jan 3, 2023
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Framework X Framework X – the simple and fast micro framework for building reactive web applications that run anywhere. Quickstart Documentation Tests

Christian Lück 620 Jan 7, 2023
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
Woski is a fast and simple lightweight PHP Framework for building applications in the realm of the web.

Woski is a simple fast PHP framework for the Realm The Project Installation Clone the repository $ composer create-project clintonnzedimma/woski myApp

Clinton Nzedimma 19 Aug 15, 2022
Simple, fast and secure PHP Framework with easy integration.

simple-php-framework Simple, fast and secure PHP Framework with easy integration.

winact 2 Nov 23, 2021