PHPackages                             n0nag0n/slim-ai-skeleton - 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. n0nag0n/slim-ai-skeleton

ActiveProject[Framework](/categories/framework)

n0nag0n/slim-ai-skeleton
========================

AI-friendly Slim 4 skeleton

v0.2.5(1mo ago)224MITPHPPHP ^8.2CI passing

Since May 17Pushed 1mo agoCompare

[ Source](https://github.com/n0nag0n/slim-ai-skeleton)[ Packagist](https://packagist.org/packages/n0nag0n/slim-ai-skeleton)[ RSS](/packages/n0nag0n-slim-ai-skeleton/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (30)Versions (19)Used By (0)

slim-ai-skeleton
================

[](#slim-ai-skeleton)

[![PHP Version](https://camo.githubusercontent.com/f90f95a1b3e0b0ded8b041fc0193ea0bdb659fd61bc16ea7cd7baae24b5a21d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](https://packagist.org/packages/n0nag0n/slim-ai-skeleton)[![Packagist Version](https://camo.githubusercontent.com/c4becb30d08ea206d69e2e5932040fbb4c425e373e1b89125a81e003cd284e22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](https://packagist.org/packages/n0nag0n/slim-ai-skeleton)[![Packagist Downloads](https://camo.githubusercontent.com/935baa98c4a26cf67bf1929a2b07f3acab55d6840e26013361ca04ddc6fae856/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](https://packagist.org/packages/n0nag0n/slim-ai-skeleton)[![License](https://camo.githubusercontent.com/87ed3d805755c02f9c3ca3363ceff9aa3c7fb673f503319a48a3098ecdbc1c5a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](LICENSE)[![GitHub Stars](https://camo.githubusercontent.com/cd89535eef525ac587de7985cab7e453e21797014ddb5d91ff281b29da26a477/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](https://github.com/n0nag0n/slim-ai-skeleton)[![Last Commit](https://camo.githubusercontent.com/1753bf05a30b8fbfb69bbceb26f12aef3ab1beb2178dcf19f719a06381d80047/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6e306e6167306e2f736c696d2d61692d736b656c65746f6e)](https://github.com/n0nag0n/slim-ai-skeleton)[![AI Friendly](https://camo.githubusercontent.com/33827e2d7bf557ba7110ff39c634529fc0030c18746c1b1d73e815329bcaa602/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41492d467269656e646c792d3542354244373f6c6f676f3d6f70656e6169266c6f676f436f6c6f723d7768697465)](AGENTS.md)[![CI](https://camo.githubusercontent.com/288078a1698b8f809da81990bfc85846955acb61489a9f5af6676ba07838aae3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e306e6167306e2f736c696d2d61692d736b656c65746f6e2f63692e796d6c3f6272616e63683d6d6173746572)](.github/workflows/ci.yml)

A starter project for building PHP web apps with the [Slim 4](https://www.slimframework.com/) framework. It's designed to work well with AI coding tools (Cursor, Claude Code, Windsurf, etc.) — the code is simple, explicit, and easy for both humans and AIs to understand.

What you get
------------

[](#what-you-get)

A working web app out of the box — it serves a homepage, a health-check endpoint, and has a database ready to go. Everything is set up so you can start adding your own pages and features immediately.

Features
--------

[](#features)

- **Slim 4** — a lightweight PHP framework for handling web requests and responses
- **PHP-DI** — automatic dependency injection container
- **Doctrine DBAL** — database query layer with parameterized queries
- **Twig** — a template system for building HTML pages separate from your PHP code
- **Session handling** — `App\Util\Session` wraps PHP's native sessions and is injectable via constructor
- **Flash messages** — one-request survival messages for form submission feedback via `App\Util\Flash`
- **Validation** — method-chaining input validation with `App\Util\Validator` (required, email, length, matches, etc.)
- **Pagination** — offset/limit calculator with `App\Util\Pagination` for list endpoints
- **CLI console** — `php console` with commands to scaffold controllers, models, migrations, and more
- **Tracy** — a debug bar with panels for requests, responses, routes, sessions, and database queries
- **PHPUnit** — testing framework to make sure your code works
- **PHPStan** — static analysis to catch bugs before runtime
- **PHP\_CodeSniffer** — enforces consistent code style
- **SQLite by default** — file-based database, no need for MySQL or PostgreSQL. Swap to MariaDB/MySQL/PostgreSQL anytime — Docker compose files are preconfigured.
- **Security static analysis** — PHPStan rules (via `spaze/phpstan-disallowed-calls`) ban superglobals, dangerous functions, weak hashing, and raw query methods in `src/`
- **Dependency vulnerability scanning** — `composer security:check` scans `composer.lock` against the Security Advisories database for known CVEs

How AI fits in
--------------

[](#how-ai-fits-in)

AI coding tools work best when code is predictable and easy to trace. This project follows patterns that AIs recognize:

- **All routes in one file** (`config/routes.php`) — the AI always knows where to add a new URL
- **No magic** — every import is explicit, no auto-discovery, no hidden configuration
- **One file per concept** — controllers handle HTTP, models handle data, templates handle HTML

If you're using an AI coding assistant, just open this project in your editor and the AI will already understand the patterns. The file `AGENTS.md` contains detailed instructions for AI tools.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- [Composer](https://getcomposer.org/)
- SQLite extension (`pdo_sqlite`) — usually included with PHP by default, no database server needed

> **Want MariaDB/MySQL or PostgreSQL?** The `.env.example` has connection settings and a `docker-compose.yml` is included to spin up a MariaDB instance. Switch `DB_DRIVER` in `.env` and you're set.

Quick Start
-----------

[](#quick-start)

```
composer create-project n0nag0n/slim-ai-skeleton my-project
cd my-project
composer migrate
composer start
```

Open `http://localhost:8080` in your browser. You should see the homepage.

Commands
--------

[](#commands)

CommandDescription`composer start`Start the development server on port 8080`composer test`Run all tests`composer lint`Check code style with PHP\_CodeSniffer`composer stan`Run PHPStan static analysis`composer cs-fix`Auto-fix code style issues`composer migrate`Run pending database migrations`composer security:check`Scan dependencies for known vulnerabilities`php console`List all CLI commands (scaffolding, cache, routes)`composer sync-ai-instructions`Sync AGENTS.md to AI tool config filesYour first new page
-------------------

[](#your-first-new-page)

Here's how to add a new page at `/hello`:

1. **Add a route** in `config/routes.php`:

    ```
    $app->get('/hello', [App\Controller\HelloController::class, 'index']);
    ```
2. **Create a controller** at `src/Controller/HelloController.php`:

    ```
