# Intent-Framework **Repository Path**: wfdaj/Intent-Framework ## Basic Information - **Project Name**: Intent-Framework - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-31 - **Last Updated**: 2026-04-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

PHP 8.2+ Composer Tests PHPStan Level 9 Version

Latest Version Total Downloads CI Status

Built by non-expert Time taken AI powered

Intent Framework

A zero-boilerplate, AI-native, explicitly designed PHP micro-framework

~3,000 lines of core code. No magic. No facades. No providers.
Just PHP that reads like English.

Yes, most of this was written by AI. Yes, I'm not a PHP expert. No, I don't care.

> ⚠️ **Early Development** β€” Intent is functional and tested (220 tests, 393 assertions!), but it's still young. Perfect for side projects, learning, and experimentation. Not yet battle-tested in production. Bugs? Probably. PRs? Welcome. --- ## ⚑ Quick Look ```php // Route with middleware Route::get('/dashboard', fn($req, $res) => $res->json([ 'user' => user(), 'stats' => cache('dashboard_stats'), ]))->middleware(AuthMiddleware::class); // Validation $v = validate($request->json(), [ 'email' => 'required|email', 'password' => 'required|min:8', ]); if ($v->fails()) { return $response->json(['errors' => $v->errors()], 422); } // Database (v0.8+ helper syntax) $users = db()->table('users')->get(); // Cache with remember pattern $stats = cache()->remember('stats', 3600, fn() => db()->table('stats')->first() ); // Events Event::listen('user.created', fn($user) => sendWelcomeEmail($user)); event('user.created', $newUser); ``` --- ## πŸ€” Why Intent Exists I was tired of: - **Laravel's 100k+ lines** and magic I couldn't trace - **Facades and containers** that hide what's actually happening - **Convention over configuration** that confused AI assistants - **Frameworks that require a PhD** to understand the request lifecycle I wanted something: - **Simple enough for AI to generate correct code** consistently - **Explicit enough that I could read any file** and understand it - **Small enough to learn in one sitting** (~3k lines total) - **Powerful enough to build real apps** without reaching for Laravel Intent is that framework. --- ## πŸ”₯ Addressing the Roasts This project was posted on r/PHP and got absolutely flamed. Let me own that: | The Criticism | The Reality Now | |---------------|-----------------| | "AI-generated slop" | Yes, AI-assisted β€” and it's clean, tested, and consistent | | "No tests" | **220 tests, 393 assertions** via PHPUnit | | "Incomplete" | v0.8.1 has middleware, auth, sessions, events, cache, CLI, registry proxies | | "No Composer" | Full `composer.json`, PSR-4 autoloading, proper `vendor/` | | "Bad structure" | `public/` separation, `src/Core/` for framework, `app/` for user code | | "Just use Laravel" | Sure β€” if you want facades and service containers. This is the opposite. | > The whole point of Intent is that it's **readable, predictable, and AI-friendly**. > Whether a human or an AI writes the code, it should be obvious what it does. --- ## πŸ›‘οΈ Quality Gates | Tool | Level | Status | |------|-------|--------| | **PHPStan** | Level 9 | βœ… Passing | | **PHPUnit** | 220 tests | βœ… Passing | | **GitHub Actions** | CI/CD | βœ… Automated | > All quality checks run automatically on every push and pull request. --- ## ✨ Key Features | Feature | Description | |---------|-------------| | **Immutable Request** | Readonly properties, no mutation bugs | | **Fluent Response** | `$res->status(201)->json($data)` | | **Middleware Pipeline** | Per-route, no global stack magic | | **Session + Flash** | `session('key')`, `flash('success', 'Saved!')` | | **Auth** | `auth()->attempt()`, `user()`, password hashing | | **Events** | Simple dispatcher: `event('user.created', $user)` | | **Cache** | File-based: `Cache::remember('key', 3600, $fn)` | | **Validator** | 18 rules: `'email' => 'required|email|max:255'` | | **Query Builder** | OR conditions, type casting, multi-DB support | | **Dev Schema** | Auto-creates tables in dev mode (disabled in prod) | | **Secure File Routes** | Outside `public/`, in `app/Api/` | | **CLI Tool** | `php intent serve`, `php intent make:handler` | | **Registry Proxies** | Type-safe service access with PHPStan Level 9 support | --- ## πŸ”„ Service Access Pattern (v0.8+) All services are accessed via **registry-backed helpers** for consistency and testability: ```php // βœ… Canonical pattern (v0.8+) db()->table('users')->where('id', 1)->first(); auth()->user(); cache('key', $value, 3600); session('user_id'); logger()->info('Message'); // ❌ Deprecated (still works, avoid in new code) DB::table('users')->get(); // Use db() instead Cache::put('key', $value); // Use cache() instead ``` > Static facades will be removed in v2.0. Use helpers for new code. --- ## πŸ“¦ Installation **Option 1: Composer (Recommended)** ```bash composer create-project intent/framework my-app cd my-app php intent serve ``` **Option 2: Clone** ```bash git clone https://github.com/aamirali51/Intent-Framework.git my-app cd my-app composer install ``` **Option 3: Using as Library** If you want to use Intent Framework as a dependency in an existing project: ```bash composer require intent/framework ``` **Important Notes:** 1. **Define `BASE_PATH` first** β€” Must be set before anything else 2. **Let `Core\App` handle initialization** β€” Don't load routes manually before App is constructed 3. **Config uses flat dot-notation keys** β€” e.g., `'app.name'`, not nested arrays **Example bootstrap:** ```php run(); ``` > ⚠️ The App constructor initializes the Router internally via `Route::setRouter()`. If you load routes before constructing App, the router won't be initialized. --- ## πŸš€ Quick Start ```bash # Start the development server php intent serve # Or manually php -S localhost:8080 -t public ``` Visit **http://localhost:8080** β€” you should see the welcome page. --- ## πŸ› οΈ CLI Commands ```bash php intent --help # Show all available commands php intent serve # Start dev server (port 8080) php intent serve 3000 # Custom port php intent cache:clear # Clear all cached data php intent make:handler # Create a handler class php intent make:middleware # Create a middleware class php intent routes # List registered routes ``` --- ## πŸ“š Documentation - **[API Reference](./API.md)** β€” Complete API with input/output types for every method - **[Architecture](./ARCHITECTURE.md)** β€” Technical docs, directory structure, and internals --- ## πŸ§ͺ Testing ```bash # Run all tests composer test # Or directly vendor/bin/phpunit ``` **Current coverage:** 220 tests, 393 assertions --- ## πŸ’‘ Philosophy ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Zero Boilerplate β”‚ β”‚ ─────────────── β”‚ β”‚ No service containers. No providers. β”‚ β”‚ No facades. No annotations. β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Explicit Over Magic β”‚ β”‚ ────────────────── β”‚ β”‚ Every line does what it says. β”‚ β”‚ No hidden behavior. No surprises. β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ AI-Native Patterns β”‚ β”‚ ───────────────── β”‚ β”‚ Consistent, predictable code that AI β”‚ β”‚ assistants can read and extend correctly. β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Minimal Abstraction β”‚ β”‚ ─────────────────── β”‚ β”‚ Thin wrappers over PHP. Not frameworks β”‚ β”‚ on top of frameworks. β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ—ΊοΈ Roadmap - [x] Route groups with shared middleware - [x] CSRF protection middleware - [x] Rate limiting middleware - [x] Logging system (`Log` class + helpers) - [x] Package auto-discovery bootstrap - [x] `intent/auth` package (API tokens, OAuth) - [ ] Full CMS demo application - [ ] Package ecosystem --- ## 🀝 Contributing Contributions welcome! Especially if you want to prove it's not "slop" πŸ˜„ 1. Fork the repo 2. Create a feature branch 3. Write tests for your changes 4. Submit a PR Check out the [ARCHITECTURE.md](./ARCHITECTURE.md) first to understand the codebase. --- ## πŸ“„ License MIT License. See [LICENSE](./LICENSE) for details. ---

Built with AI assistance by a non-expert. Shipped anyway.

Roast me again on r/PHP if you want. I'll be here shipping v0.8.1.