GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yourjhay/simple-php: Lightweight PHP Framework

BranchesTags
Open more actions menu

Latest commit

 

History

235 Commits
235 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
database
database
 
 
public
public
 
 
storage
storage
 
 
.env.example
.env.example
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG
CHANGELOG
 
 
Procfile
Procfile
 
 
README.md
README.md
 
 
cli
cli
 
 
composer.json
composer.json
 
 
queryBuilder.md
queryBuilder.md
 
 
simply concept.png
simply concept.png
 
 

Repository files navigation

The Simply PHP Framework

Latest Stable Version Total Downloads License Monthly Downloads

About Simple

The Simple PHP is a lightweight web application micro framework.

  • Model, View, Controller Pattern
  • Simple Routing engine with regex variables, groups, HTTP method filters
  • Auto-wiring controller method arguments (Request, FormRequest, services)
  • FormRequest validation with automatic validation before controller execution
  • Full-featured validation library (76+ rules, 16+ filters, custom callbacks)
  • CLI console with generators (controllers, models, requests, observers, auth)
  • Uses Twig Template Engine (optional, plain HTML also supported)
  • Resource-friendly database connectivity (PDO)
  • Environment Configuration (.env)
  • Error handling and logging (Whoops for dev, clean error pages for production)
  • Controller action suffix for auth middleware (before/after hooks)
  • Encryption library (defuse/php-encryption)
  • Resource routes
  • PSR-4 autoloading with namespaces

FULL DOCUMENTATION

https://simply.rjhon.net

Installation

Via Composer (recommended):

composer create-project reyjhon/simple-php
cd simple-php

Quick Start

Basic Route

Router::set('/', ['controller' => 'home', 'action' => 'index']);

Controller with Auto-wired Request

use Simple\Request;

class HomeController extends Controller
{
    public function index(Request $request)
    {
        $name = $request->get('name');
        return view('home.index', ['name' => $name]);
    }
}

FormRequest Validation

Generate a form request:

php cli make:request StoreProductRequest

Use it in a controller:

use App\Requests\StoreProductRequest;

class ProductController extends Controller
{
    public function store(StoreProductRequest $request)
    {
        $data = $request->validated();
        Product::create($data);
        return view('product.show', ['product' => $data]);
    }
}

VIEWS

This micro framework uses Twig for the template engine. But it is optional. You can use plain HTML without Twig.

  • Views must be located in app/Views directory.
  • All views must be named with suffix view before the file extension. e.g.: welcome.view.html, product.view.html
  • View cache can be enabled or disabled in the application config.

When rendering a view (with Twig):

return view('welcome');

When a view is inside a folder, include the folder then view name separated by a period:

return view('your_folder.welcome');

Please read the Twig documentation for more information: https://twig.symfony.com/doc/3.x/

NOTE:

  • Views must be a valid HTML file: e.g. welcome.view.html
  • Layout files can be Twig files: e.g. layout.twig, master.twig

When rendering a plain HTML view:

Pass a third parameter 'normal' to render without the template engine:

return view('welcome', [], 'normal');

NOTE:

  • Views must be valid PHP files: e.g. welcome.view.php
  • Normal rendering does not support inheritance
  • The second parameter holds variables to pass. If empty, it must be initialized.

Validation

Simply includes a full validation library with 76+ validation rules and 16+ filters.

use Simple\Validation\Validator as Validate;

$result = Validate::is_valid($_POST, [
    'name'  => 'required|min_len:3|max_len:255',
    'email' => 'required|valid_email',
    'age'   => 'required|numeric|min_numeric:18',
]);

Read the full validation documentation at: https://simply.rjhon.net/documentation/v1/lib/validation

Encryption

Simply offers encryption using defuse/php-encryption.

Run this command once:

php cli key:generate

Encrypt

use Simple\Security\SimplyEncrypt;

$encrypted = SimplyEncrypt::encrypt('secret text');

Decrypt

use Simple\Security\SimplyDecrypt;

$decrypted = SimplyDecrypt::decrypt($ciphertext);

CLI Commands

Command Description
php cli make:controller Generate a controller
php cli make:model Generate a model
php cli make:request Generate a FormRequest class
php cli make:observer Generate an observer
php cli make:auth Scaffold authentication
php cli serve Start PHP development server
php cli key:generate Generate application key
php cli route:list List all registered routes

Routing

Basic

Router::set('products', [
    'controller' => 'ProductController',
    'action'     => 'index'
]);

With variables

Router::set('products/{id:\d+}', [
    'controller' => 'ProductController',
    'action'     => 'show'
]);

Resource routes

Router::resource('products', 'ProductController');
// Generates: index, create, store, show, edit, update, destroy

Route groups

Router::group('admin', function () {
    Router::get('users', ['controller' => 'AdminController', 'action' => 'users']);
});

Full FQCN

Router::set('admin/{action}', [
    'controller' => 'App\Controllers\Admin\AdminController'
]);

Coding Style

PSR-12 Extended Coding Standard: https://www.php-fig.org/psr/psr-12/

Dependencies

  • Twig Template Engine
  • vlucas/phpdotenv

About

Lightweight PHP Framework

simply.rjhon.net/

Topics

frameworkmicro-frameworkphpphp-frameworks

Resources

Readme
Activity

Stars

3 stars

Watchers

3 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.