A lightweight, modern PHP 8+ web framework skeleton for building REST APIs and web applications.
✓ Lightweight & Fast — Minimal overhead, optimized for performance ✓ PHP 8+ — Modern PHP with strict typing and attributes ✓ REST APIs — JSON routing and controllers with built-in helpers ✓ PSR Compliant — PSR-3, PSR-7, PSR-11, PSR-16, PSR-17 standards ✓ Flexible Configuration — JSON config with environment variable expansion ✓ Database Support — MySQL, PostgreSQL, SQLite, Firebird, CockroachDB ✓ Middleware Pipeline — Global, group, and route-level middleware ✓ Caching — APCu, Redis, and file-based cache adapters ✓ Logging — Monolog integration with configurable drivers ✓ Tested — PHPUnit test suite included
git clone https://github.com/Celarius/spin-skeleton.git myapp
cd myappcomposer installcp .env.example .env
# Edit .env with your settingsphp -S localhost:8000 -t src/publiccurl http://localhost:8000/api/healthExpected response:
{
"status": "OK",
"code": "spin",
"name": "Spin Skeleton",
"version": "0.0.1"
}✓ Done! Your app is running. Read the documentation to build your first controller.
| Topic | File |
|---|---|
| 5-minute setup guide | Getting Started |
| Configuration and environment variables | Configuration |
| Database setup and queries (MySQL, SQLite, PostgreSQL) | Database Connections |
| Creating controllers and middleware | Controllers & Middleware |
| Writing tests with PHPUnit | Testing |
spin-skeleton/
├── src/
│ ├── app/
│ │ ├── Config/ # Configuration files (JSON)
│ │ │ ├── config-dev.json
│ │ │ ├── config-unittest.json
│ │ │ └── routes-dev.json
│ │ ├── Controllers/ # API and web controllers
│ │ │ ├── Api/
│ │ │ │ ├── HealthController.php
│ │ │ │ ├── StatusController.php
│ │ │ │ └── InfoController.php
│ │ │ ├── DefaultController.php
│ │ │ └── ExampleController.php
│ │ ├── Middlewares/ # Request/response middleware
│ │ ├── Views/ # Templates and pages
│ │ │ ├── Pages/
│ │ │ ├── Errors/
│ │ │ └── Components/
│ │ ├── Models/ # (Future) Data models
│ │ ├── Classes/ # Application classes
│ │ └── Globals.php # Global helpers registration
│ └── public/
│ ├── bootstrap.php # Application entry point
│ ├── index.php
│ └── .htaccess # Apache routing
├── tests/ # PHPUnit test suite
│ ├── Controllers/
│ ├── Middlewares/
│ ├── ApplicationTest.php
│ ├── bootstrap.php
│ └── phpunit.xml
├── doc/ # Documentation guides
│ ├── getting-started.md
│ ├── configuration.md
│ ├── database-connections.md
│ ├── controllers-and-middleware.md
│ └── testing.md
├── vendor/ # Composer dependencies
├── .env # Environment variables (create)
├── .gitignore
├── composer.json
├── composer.lock
└── phpunit.xml
- Create a controller in
src/app/Controllers/Api/ - Extend
Spin\Core\Controller - Implement
handleGET(),handlePOST(), etc. - Register in
src/app/Config/routes-dev.json
- Configure connection in
config-dev.json - Set
.envvariables for credentials - Use
app()->getConnection()in controllers
Supports: MySQL, PostgreSQL, SQLite, Firebird, CockroachDB
- Create test file in
tests/ - Extend
PHPUnit\Framework\TestCase - Use
composer testto run
- Edit
src/app/Config/config-dev.json - Use environment variables with
${env:VAR} - Access with
config('key.path')helper
- Create class extending
Spin\Core\Middleware - Implement
initialize()andhandle()methods - Register in config or routes
<VirtualHost *:80>
ServerName myapp.local
DocumentRoot /var/www/myapp/src/public
<Directory /var/www/myapp/src/public>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ bootstrap.php [QSA,L]
</Directory>
</VirtualHost>FROM php:8.2-cli
RUN apt-get update && apt-get install -y git unzip
RUN curl https://getcomposer.org/composer.phar -o /usr/local/bin/composer && chmod +x /usr/local/bin/composer
WORKDIR /app
COPY . .
RUN composer install --optimize-autoloader --no-dev
EXPOSE 8000
CMD ["php", "-S", "0.0.0.0:8000", "-t", "src/public"]Build and run:
docker build -t spin-skeleton .
docker run -p 8000:8000 spin-skeleton- PHP 8.0+
- celarius/spin-framework — Core framework
- league/plates — Template engine
- phpunit/phpunit — Testing framework (dev)
See composer.json for all dependencies.
Run the test suite:
composer testWith coverage report:
./vendor/bin/phpunit --coverage-html coverage/MIT License — see LICENSE for details
Kim Sandell (sandell@celarius.com)
Resources: