ApnaPHP is a modern PHP framework built by Also Coder. It brings Next.js-style file-based routing to PHP, with a Laravel-like ORM, automatic migrations, hierarchical middleware, 30+ validation rules and a powerful CLI — so you can ship APIs and full-stack apps without boilerplate setup.
We use ApnaPHP for client backends, REST APIs, admin panels and MVPs where PHP hosting is preferred and developers want convention over configuration.
Why ApnaPHP
| Feature | Benefit |
|---|---|
| File-based routing | Add a file → get a route. No route config files. |
| Eloquent-style ORM | Models, relationships, query scopes, auto-migrations |
| Multi-database | MySQL, PostgreSQL, SQLite and MongoDB behind one API |
| Class-based API handlers | Clean GET / POST methods per route file |
| Built-in validation | 30+ rules, file uploads, conditional validation |
| Zero config defaults | Sensible out-of-the-box — customize when you need to |
Core features
- File-based routing — pages and API routes by filesystem layout (Next.js inspired)
- ORM with auto-migration — Laravel-like models; supports MySQL, PostgreSQL, SQLite, MongoDB
- Middleware system — hierarchical auth, CORS, security and custom middleware
- Powerful CLI —
php apna make:route, models, migrations, middleware; built-in dev server - Advanced validation — file uploads, conditional rules, custom validators
- File upload system — public/private storage with validation and path handling
- Error handling — debug pages with stack traces and code preview
- Console logging —
console_info(),console_error(),console_debug() - SEO & metadata — Open Graph and Twitter Card helpers
- Layout system — hierarchical layouts with metadata merging
- Dynamic routes —
[id],[slug]parameters with automatic matching - DI container — service container for clean architecture
- Security — CSRF, XSS prevention, secure headers, input sanitization
Quick example
Create route.apna.php — class-based handler:
<?php
namespace App\Api\Users;
use ApnaPHP\Routing\Request;
use ApnaPHP\Routing\Response;
use App\Models\User;
class UsersHandler {
public function GET(Request $request) {
return Response::json([
'success' => true,
'users' => User::all()
]);
}
}
No route registration file — the framework discovers routes from your folder structure.
Get started in 3 steps
1. Install dependencies
composer install
2. Create your first route
php apna make:route about
3. Start the dev server
php apna serve
Your app runs at http://localhost:3000 with hot reload during development.
Perfect for
- PHP startups & MVPs — launch faster with file-based routing and CLI generators
- REST APIs — class-based handlers, validation and multi-DB support
- Web applications — full-stack PHP with layouts and metadata
- Microservices — lightweight services with minimal overhead
What you get out of the box
- 30+ validation rules — including file uploads and conditional validation
- 100+ CLI commands — routes, models, migrations, middleware scaffolding
- 4 database drivers — switch databases without rewriting your app layer
- Template directives — optional Blade-like
@if,@foreach,@include(plain PHP also fine) - Production-ready — security headers, CSRF, error handling, logging
Comparison mindset
ApnaPHP sits between “raw PHP” and heavy full-stack frameworks:
- Faster to start than configuring Laravel/Symfony for small APIs
- More structure than plain PHP or micro-frameworks
- Familiar if you know Next.js routing or Laravel models
Built by Also Coder
ApnaPHP is maintained by the same team that ships client projects on Also Coder. Need a PHP API, migration from legacy code, or a full product on ApnaPHP? Use the form on this page.
Links
- Website: apnaphp.com
- Documentation: available on the ApnaPHP site
- GitHub: github.com/alsocoders/apnaphp
- Packagist: search
alsocoder/apnaphpon Packagist
Ready to build something together?
Tell us about your website, app or automation idea. We'll reply with scope, timeline and cost — no sales script.
Your move