Get your first SPIN Framework application up and running in just a few minutes. This guide walks you through installation, creating a route, and testing your first endpoint.
- PHP 8.0 or higher
- Composer
- Basic familiarity with command line
- A text editor or IDE
Create a new project directory:
mkdir my-first-app
cd my-first-appInitialize a Composer project:
composer initAnswer the prompts (or use defaults), then add SPIN Framework as a dependency:
composer require celarius/spin-frameworkCreate the project structure:
mkdir -p src/app/Controllers
mkdir -p src/app/Config
mkdir publicCreate src/app/Config/version.json:
{
"application": {
"code": "my-first-app",
"name": "My First App",
"version": "0.1.0"
}
}The framework loads this file automatically at startup. Access the values at runtime:
app()->getAppCode(); // "my-first-app"
app()->getAppName(); // "My First App"
app()->getAppVersion(); // "0.1.0"
codeis also used as the Monolog log channel name and storage path identifier.
Create src/app/Controllers/WelcomeController.php:
<?php declare(strict_types=1);
namespace App\Controllers;
use Spin\Core\Controller;
use Psr\Http\Message\ResponseInterface;
class WelcomeController extends Controller
{
public function handleGET(array $args): ResponseInterface
{
return responseJson([
'message' => 'Welcome to SPIN Framework!',
'timestamp' => date('Y-m-d H:i:s')
]);
}
}Create src/app/Config/routes.json:
{
"common": {
"before": [],
"after": []
},
"groups": [
{
"name": "Welcome Routes",
"notes": "Basic welcome endpoint",
"prefix": "/api",
"before": [],
"routes": [
{
"methods": ["GET"],
"path": "/welcome",
"handler": "\\App\\Controllers\\WelcomeController"
}
],
"after": []
}
],
"errors": {}
}Create public/index.php:
<?php declare(strict_types=1);
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Spin\Application;
$app = new Application(
projectPath: dirname(__DIR__),
configFile: 'routes.json',
environment: 'dev'
);
$app->run();Use PHP's built-in server:
php -S localhost:8000 -t public/You'll see output like:
Development Server (http://localhost:8000)
Listening on http://localhost:8000
In a new terminal, test your endpoint:
curl http://localhost:8000/api/welcomeOr using Postman:
- Create a new GET request to
http://localhost:8000/api/welcome - Send the request
- See the JSON response
You should receive:
{
"message": "Welcome to SPIN Framework!",
"timestamp": "2026-03-15 14:23:45"
}- Controller — PHP class handling the GET request
- Route — JSON definition mapping
/api/welcometo your controller - Global Helper —
responseJson()sends JSON responses - Application — Main orchestrator loading config and routing requests
- Read Project-Structure.md to understand the framework layout
- Explore Core-Concepts.md to understand how it all works
- Try Your-First-App.md to build a complete CRUD API
- Check User-Guide/Routing.md for advanced routing patterns
Port 8000 already in use?
php -S localhost:8001 -t public/Routes not found (404)?
- Verify route path matches your request exactly (case-sensitive)
- Check controller fully-qualified class name matches route handler
- Restart the development server after config changes
Blank response?
- Check PHP error logs:
php -S localhost:8000 -t public/ 2>&1 - Verify namespace and controller class name are correct
- spin-skeleton — Complete example application
- User-Guide/Configuration.md — Configuration details
- User-Guide/Routing.md — Advanced routing features