Skip to content
/ spe Public

A series of PHP8 examples based around a super simple MVC framework (WIP)

License

Notifications You must be signed in to change notification settings

markc/spe

Repository files navigation

SPE - Simple PHP Examples

Copyright (C) 2015-2025 Mark Constable [email protected] (AGPL-3.0)

This is a very simple PHP8.4 "framework" that will be expanded to include more small project examples building on the first very lean foundation and incorporating additional functionality in each successive example.

Quick Start

This is the easiest way to display and develop this project...

    bash -c "$(curl -fsSL https://php.new/install/linux)"
    [[ ! -d ~/Dev ]] && mkdir ~/Dev
    cd ~/Dev
    git clone https://github.com/markc/spe
    cd spe
    export PATH=$PATH:~/.config/herd-lite/bin
    composer install
    php -S localhost:8000

The Examples

Each folder will contain a more comprehensive example of a working, and hopefully useful, sub-projects with a README.md explaining each example.

  • 01-Simple

    At 140 LOC this is about the simplest 3 page example of this particular framework style I could come up with. It is a self-contained single script with all code encapsulated within a single anonymous class and one echo.

    Key Features:

    • Single File Architecture
    • Type Safety
    • Modern PHP 8.4
    • Clean URL Routing
    • XSS Protection
    • Responsive Design
  • 02-Styled

    Funcionally similar to the above barebones example but with a small amount of inline CSS to provide a minimum of style along with the Roboto font from Google CDN.

    Key Differences:

    • Integrated Bootstrap 5 styling
    • Flexible navigation system
    • Modern PHP 8.x features
  • 03-Plugins

    A simple example of providing "plugins" which are basically the model of the traditional MVC coding style. It also includes a simple AJAX link on the About page that dumps the main global output array using the ultra simple remote XHR API. There is also an example of passing a success/error message back into the same page but it will be replaced with session vars in one of the next examples.

    Key Components:

    • Config Class
    • Init Class
    • Plugin Abstract Class
    • Concrete Plugin Classes
    • Util Class
  • 04-Themes

    Extend the above example to include basic themeing classes and methods.

    TODO: write doc

  • 05-Autoload

    Add PSR-4 autoload via composer.

    Key Features:

    • Plugin Architecture
    • Theme System
    • Context Management
    • Logging
    • Responsive Design
    • AJAX Support
  • 06-Session

    TODO: write doc

  • 07-PDO

    TODO: write doc

  • 08-Users

    TODO: write doc

  • 09-Auth

    TODO: write doc

  • 10-Files

    TODO: write doc

The associated example README files will act as both code comments and general documentation for each project.

About

A series of PHP8 examples based around a super simple MVC framework (WIP)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published