A super lightweight PHP UI/REST Framework

dev-master 2021-05-06 09:51 UTC

This package is auto-updated.

Last update: 2021-06-06 09:59:26 UTC


Latest Stable Version Total Downloads License PHP7 Ready

Spin - A super lightweight PHP UI/REST framework

Latest Unstable Version Build Status

Spin is a application framework for making Web UI's and REST API's quickly and effectively with PHP. It uses PSR standards for most things, and allows for plugging in almost any PSR compatible component, such as loggers, HTTP libraries etc.

    NOTE: This framework is in RC stage - Please contribute to make it complete

1. Features

  • PHP 7.1+
  • Platform agnostic. (Windows, *nix)
  • Routing engine, with route groups
  • Middleware
  • Containers
  • Composer driven in packages/extensions
  • PDO based DB connections (MySql,PostgreSql,Oracle,CockroachDb,Firebird,Sqlite ...)
  • DAO base classes for DB Entity representation
  • Extendable with other frameworks (ORM, Templates etc.)

1.1. PSR based integrations

  • Logger (PSR-3) Defaults to Monolog
  • HTTP Message (PSR-7). Defaults to Guzzle
  • Container (PSR-11). Defaults to The Leauge Container
  • SimpleCache (PSR-16). Defaults to APCu SimpleCache
  • HTTP Factories (PSR-17)

2. Installation

Installing spin-framework as standalone with composer:

composer require celarius/spin-framework

2.1. Using the spin-skeleton

To install and use the spin-framework it is highly recommended to start by cloning the spin-skeleton and running composer update -o in the folder. This will download all needed packages, and create a template skeleton project, containing example configs, routes, controllers and many other things.

2.2. Testing

Having PHPUnit installed simply type


At the command prompt and all tests will be executed.

3. Technical Details

3.1. Apache VHost configuration

VHost for running the application under Apache with domain-name recognition.

If Port number based applications are desired the <VirtualHost:80> needs to change to the corresponding port, and the domain.name removed from the config.

<VirtualHost *:80>

    Define domain.name              mydomain.com
    Define alias.domain.name        www.mydomain.com
    Define path_to_root             C:/Path/Project
    Define environment              DEV

    ServerName ${domain.name}
    ServerAlias ${alias.domain.name}
    ServerAdmin webmaster@${domain.name}

    DocumentRoot "${path_to_root}\src\public"

    ErrorLog "logs/${domain.name}.error.log"
    CustomLog "logs/${domain.name}.access.log" common

    # Default caching headers for static content in /public
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
      Header set Cache-Control "public, max-age=604800, must-revalidate"

    <Directory "${path_to_root}\src\public">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted

        # Set Variables
        SetEnv ENVIRONMENT ${environment}

        # Load files in this order on "/"
        DirectoryIndex bootstrap.php index.php index.html

        # Disable appending a "/" and 301 redirection when a directory
        # matches the requested URL
        DirectorySlash Off

        # Set Rewrite Engine ON to direct all requests to
        # the `bootstrap.php` file
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ bootstrap.php [QSA,L]