celarius/spin-framework

A super lightweight PHP UI/REST Framework

dev-master 2017-11-16 19:17 UTC

README

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 ALPHA stage - Not ready for production

1. Features

  • PHP 7.1+
  • Platform agnostic. (Windows, *nix)
  • Composer driven in all packages/extensions
  • PDO based DB connections (MySql,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
  • Huggable (PSR-8)
  • HTTP Message (PSR-7). Defaults to Guzzle
  • Container (PSR-11). Defaults to The Leauge Container
  • Events (PSR-14).
  • 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.

4. Technical Details

Apache VHost configuration

<VirtualHost *:80>
    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"
    </FilesMatch>

    <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]
    </Directory>
</VirtualHost>