[■]
codesaur/raptor
1=[↕]
1:1 ══ composer create-project codesaur/raptor my-project
codesaur/raptor · v5.7.2
Raptor
Clean architecture object-oriented web development framework
[■]
Raptor
A multi-layered, multi-tenant, full-featured CMS PHP web framework built on PSR standards with RBAC access control. It ships with two apps by default - Web (public website) and Dashboard (admin panel) - and brings the other codesaur ecosystem packages together into one working system.
Features
- PSR-7/PSR-15 middleware-based architecture
- JWT + Session authentication
- Multi-tenant organizations with RBAC
- Multi-language support (Localization) - one URL prefix per language (/en/...), canonical + hreflang emitted automatically
- Language-neutral records (code = "*") shown in every language - news, pages and products
- CMS modules: News, Pages, Files, References, Settings
- Shop module: Products, cart, multi-product orders, stock tracking (subtracted on confirmation, restored on cancel), Reviews
- MySQL or PostgreSQL supported
- SQL file-based database migration system
- codesaur/template engine (Twig-style syntax, XSS protection through autoescape)
- OpenAI integration (moedit editor)
- PSR-3 logging, PSR-14 Event Dispatcher
- Email (Brevo API, SMTP, PHP mail), Discord webhook notifications
- SEO: Search, Sitemap, XML Sitemap, RSS feed
- Spam protection (honeypot, HMAC token, rate limiting, Cloudflare Turnstile)
- CSRF protection
- Runs in any environment: VPS, dedicated, cloud or shared hosting - method override and body encoding keep it working even behind a mod_security / LiteSpeed WAF
- File-based cache (PSR-16), Trash recovery, sidebar badge system
Core classes
| Class | Purpose |
|---|---|
Dashboard\Application | Admin panel middleware + router registration |
Web\Application | Public website middleware + router registration |
Dashboard\DatabaseConnection | Opens the PDO connection - MySQL / PostgreSQL chosen in .env |
Dashboard\Controller | Base for all controllers: PDO, RBAC, template, log |
Dashboard\MethodOverrideMiddleware | Restores PUT/PATCH/DELETE from X-HTTP-Method-Override (WAF) |
Dashboard\BodyEncodingMiddleware | Decodes base64-encoded POST bodies (WAF) |
Dashboard\ContainerMiddleware | Injects the PSR-11 container and its services into the request |
Dashboard\SessionMiddleware | Opens the session and closes it early when no write is needed |
Dashboard\Authentication\JWTAuthMiddleware | Validates the JWT and builds the User object |
Dashboard\Localization\LocalizationMiddleware | Determines language and translations |
Dashboard\Content\SettingsMiddleware | Injects the system settings into the request |
Dashboard\CsrfMiddleware | Per-route CSRF protection |
Dashboard\Authentication\User | The signed-in user: can(), is(), organization scope |
Dashboard\RBAC\RBAC | A user roles and permissions set (cached) |
Dashboard\Template\DashboardTrait | dashboard.html layout, sidebar and organization switcher |
Web\Template\TemplateController | Web index.html layout, SEO meta and navigation |
Web\Shop\Cart | Session cart - stores only [product_id => quantity], prices and stock are re-read from the DB |
Dashboard\CacheService | PSR-16 file-based cache |
Dashboard\Log\Logger | PSR-3 logging into the {table}_log tables |
Dashboard\Mail\Mailer | Mailer (Brevo API, SMTP, PHP mail) |
Dashboard\Notification\EventDispatcher | PSR-14 event dispatcher |
Dashboard\Notification\DiscordNotifier | Discord webhook notifications |
Dashboard\Migration\MigrationRunner | Runs SQL migration files with a driver-aware statement splitter |
Dashboard\Migration\MigrationSecurityScanner | Flags writes to sensitive tables and DCL statements |
Dashboard\Trash\TrashModel | Stores deleted records and restores them |
Dashboard\File\FileController | Base logic for file uploads and deletion |
Dashboard\Badge\BadgeController | Counts unseen activity for the sidebar badges |
Dashboard\Exception\ErrorHandler | Template-based error pages |
Quick example
// application/web/WebRouter.php
use codesaur\Router\Router;
class WebRouter extends Router
{
public function __construct()
{
$this->GET('/', [HomeController::class, 'index'])->name('home');
$this->GET('/page/{slug}', [Content\PageController::class, 'page'])->name('page');
$this->GET('/news/{slug}', [Content\NewsController::class, 'news'])->name('news');
}
}
// application/web/HomeController.php
class HomeController extends Template\TemplateController
{
public function index()
{
$recent = (new NewsModel($this->pdo))->getRecentPublished($this->getLanguageCode());
$this->webTemplate(__DIR__ . '/home.html', ['recent' => $recent])->render();
}
}
Running tests
composer test
[■]
Info
Install
composer create-project codesaur/raptor my-project
Requirements
- PHP 8.2.1+
- Composer
- MySQL / PostgreSQL
- ext-gd
- ext-intl
Dependencies (codesaur)
- codesaur/http-message ^3.0.4
- codesaur/http-application ^7.0.1
- codesaur/dataobject ^10.2.1
- codesaur/http-client ^2.1.2
- codesaur/template ^5.0.1
- codesaur/container ^3.2.0
Documentation