PHPackages                             celarius/spin-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. celarius/spin-framework

ActiveFramework[Framework](/categories/framework)

celarius/spin-framework
=======================

A super lightweight PHP UI/REST Framework

0.0.39(1mo ago)816.4k6[1 issues](https://github.com/Celarius/spin-framework/issues)MITPHPPHP ^8CI passing

Since Aug 19Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/Celarius/spin-framework)[ Packagist](https://packagist.org/packages/celarius/spin-framework)[ Docs](http://spin.celarius.com)[ RSS](/packages/celarius-spin-framework/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (2)Dependencies (28)Versions (8)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/8b93bd418f184823625328a14e38020f23ecd3f1c26ec45cdaa77df3a807fbc8/68747470733a2f2f706f7365722e707567782e6f72672f63656c61726975732f7370696e2d6672616d65776f726b2f762f737461626c65)](https://packagist.org/packages/celarius/spin-framework)[![Total Downloads](https://camo.githubusercontent.com/ecd2a1e57a88fc386588925a98868a08a546b1190395bb0d63ee8f2c2ef3aed6/68747470733a2f2f706f7365722e707567782e6f72672f63656c61726975732f7370696e2d6672616d65776f726b2f646f776e6c6f616473)](https://packagist.org/packages/celarius/spin-framework)[![License](https://camo.githubusercontent.com/bd1d2147427ce2b6039204f83b8b03ede75b011dd739053d4ca1667dbdfb4087/68747470733a2f2f706f7365722e707567782e6f72672f6e6f66757a7a2f6672616d65776f726b2f6c6963656e7365)](https://packagist.org/packages/celarius/spin-framework)[![PHP8 Ready](https://camo.githubusercontent.com/cd259e45101568d98df6849b7e1b0141357ca4acfaca05c44c5d088368c8911d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850382d72656164792d677265656e2e737667)](https://packagist.org/packages/celarius/spin-framework)[![Unit Tests](https://github.com/Celarius/spin-framework/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/Celarius/spin-framework/actions/workflows/unit-tests.yml)[![Code Quality](https://camo.githubusercontent.com/1bca27642166bf048bcb6c070dc4937bc566cd6fe3e85fe03ba03789eaf64d15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307175616c6974792d412d677265656e2e737667)](https://github.com/Celarius/spin-framework)[![Maintenance](https://camo.githubusercontent.com/10fe9dee46641c191d9551704c6739248966f27ea2fc60445ea7db920966bbdd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e7461696e65642d7965732d677265656e2e737667)](https://github.com/Celarius/spin-framework)

 [![SPIN Framework Logo](https://camo.githubusercontent.com/93a236884c6aea97d690514562de8881b23f6d227836d3765820e30c871f1677/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f343030783230302f3441393045322f4646464646463f746578743d5350494e2b4672616d65776f726b)](https://camo.githubusercontent.com/93a236884c6aea97d690514562de8881b23f6d227836d3765820e30c871f1677/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f343030783230302f3441393045322f4646464646463f746578743d5350494e2b4672616d65776f726b)

 **A super lightweight, modern PHP framework for building web applications and REST APIs**

🚀 About SPIN Framework
----------------------

[](#-about-spin-framework)

SPIN is a lightweight, high-performance PHP framework designed for building modern web applications and REST APIs. Built with PHP 8+ and following PSR standards, SPIN provides a clean, intuitive foundation for developers who want speed, flexibility, and simplicity without the overhead of larger frameworks.

### ✨ Why Choose SPIN?

[](#-why-choose-spin)

- **🚀 Lightning Fast** - Minimal overhead, optimized for performance
- **🔧 PSR Compliant** - Built on industry standards for maximum compatibility
- **📱 Modern PHP 8+** - Leverages the latest PHP features and performance improvements
- **🔄 Flexible Architecture** - Easy to extend and customize for your specific needs
- **📚 Comprehensive** - Built-in support for routing, middleware, caching, databases, and more
- **🌐 Platform Agnostic** - Works seamlessly on Windows, Linux, and macOS

📋 Requirements
--------------

[](#-requirements)

- **PHP**: 8.0 or higher
- **Extensions**: PDO, JSON, OpenSSL, Mbstring
- **Web Server**: Apache, Nginx, or any PSR-7 compatible server
- **Database**: MySQL, PostgreSQL, SQLite, CockroachDB, Firebird, or any PDO-compatible database

🛠️ Installation
---------------

[](#️-installation)

### Quick Start with Composer

[](#quick-start-with-composer)

```
composer require celarius/spin-framework
```

### Using the SPIN Skeleton (Recommended)

[](#using-the-spin-skeleton-recommended)

For the best development experience, start with our official skeleton project:

```
# Clone the skeleton
git clone https://github.com/Celarius/spin-skeleton.git my-spin-app
cd my-spin-app

# Install dependencies
composer install

# Start development server
php -S localhost:8000 -t src/public
```

🏗️ Project Structure
--------------------

[](#️-project-structure)

```
my-spin-app/
├── src/
│   ├── app/
│   │   ├── Config/           # Configuration files
│   │   ├── Controllers/      # Controllers
│   │   ├── Middlewares/      # Custom middleware
│   │   ├── Views/            # Template files
│   │   └── Globals.php       # Global functions
│   ├── public/               # Web root directory
│   │   ├── bootstrap.php     # Application entry point
│   └── storage/              # Application storage
│       ├── logs/             # Log files
│       ├── cache/            # Optional. Cache files
├── vendor/                   # Composer dependencies
├── composer.json             # Project dependencies

```

🚀 Getting Started
-----------------

[](#-getting-started)

### 1. Configuration

[](#1-configuration)

SPIN uses JSON-based configuration files, in the `/Config` folder, named after the environment `config-.json`:

```
{
  "application": {
    "global": {
      "maintenance": false,
      "timezone": "Europe/Stockholm"
    },
    "secret": "${env:APPLICATION_SECRET}"
  },
  "session": {
    "cookie": "SID",
    "timeout": 3600,
    "driver": "apcu"
  },
  "logger": {
    "level": "notice",
    "driver": "php"
  }
}
```

*Configuration files support `${env:}` macros for environment variables in values*

### 2. Routing

[](#2-routing)

Routes are defined in JSON configuration files:

```
{
  "common": {
    "before": ["\\App\\Middlewares\\RequestIdBeforeMiddleware"],
    "after": ["\\App\\Middlewares\\ResponseLogAfterMiddleware"]
  },
  "groups": [
    {
      "name": "Public API",
      "prefix": "/api/v1",
      "before": ["\\App\\Middlewares\\CorsBeforeMiddleware"],
      "routes": [
        { "methods": ["GET"], "path": "/health", "handler": "\\App\\Controllers\\Api\\HealthController" }
      ]
    },
    {
      "name": "Protected API",
      "prefix": "/api/v1",
      "before": ["\\App\\Middlewares\\AuthHttpBeforeMiddleware"],
      "routes": [
        { "methods": ["GET"], "path": "/users/{id}", "handler": "\\App\\Controllers\\Api\\UserController" }
      ]
    }
  ]
}
```

### 3. Controllers

[](#3-controllers)

Controllers extend SPIN's base classes and use specific HTTP method handlers:

```
