Ready-to-use starter template for ApnaPHP Framework - A modern PHP framework inspired by Next.js App Router and Laravel.
- File-based Routing: Next.js App Router style routing with
.apna.phpfiles - Laravel-like ORM: Eloquent-inspired models with schema definition
- Multiple Database Support: MySQL, MariaDB, PostgreSQL, MongoDB, SQLite
- Auto-migration: Automatic schema creation from model definitions
- Middleware Support: Hierarchical middleware system
- Console Commands: Built-in CLI with
php apna serve - Modern PHP: PHP 8.1+ with modern syntax and features
composer create-project alsocoder/apnaphp my-app
cd my-appcomposer require alsocoder/apnaphp-frameworkcomposer create-project alsocoder/apnaphp my-app
cd my-appEdit .env file:
DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=my_database
DB_USERNAME=root
DB_PASSWORD=passwordphp apna serveYour application will be available at http://localhost:3000
my-app/
βββ app/
β βββ api/ # API routes
β β βββ users/
β β βββ route.apna.php
β βββ dashboard/ # Page routes
β β βββ page.apna.php
β βββ layout.apna.php # Layout files
βββ config/
β βββ app.php
β βββ database.php
βββ models/
β βββ User.php
βββ public/
β βββ index.php
βββ storage/
βββ cache/
βββ logs/
βββ uploads/
Create routes by adding .apna.php files:
API Routes (app/api/*/route.apna.php):
<?php
use ApnaPHP\Routing\Request;
use ApnaPHP\Routing\Response;
class UsersHandler
{
public function GET(Request $request)
{
return Response::json(['users' => User::all()]);
}
public function POST(Request $request)
{
$user = User::create($request->all());
return Response::json($user, 201);
}
}Page Routes (app/*/page.apna.php):
<?php
$users = User::all();
?>
<!DOCTYPE html>
<html>
<head>
<title>Users</title>
</head>
<body>
<h1>Users</h1>
<?php foreach ($users as $user): ?>
<div><?= $user->name ?></div>
<?php endforeach; ?>
</body>
</html><?php
namespace App\Models;
use ApnaPHP\Database\Model;
class User extends Model
{
protected $table = 'users';
protected $autoMigrate = true;
protected $schema = [
'name' => 'required|type:string|length:255',
'email' => 'required|unique|type:string|length:255',
'phone' => 'nullable|type:string|length:20',
'age' => 'type:integer|min:18|max:120|default:18',
'status' => 'type:string|in:active,inactive|default:active'
];
protected $fillable = ['name', 'email', 'phone', 'age'];
protected $hidden = ['password'];
}// Create
$user = User::create([
'name' => 'John Doe',
'email' => 'john@example.com'
]);
// Find
$user = User::find(1);
$user = User::where('email', 'john@example.com')->first();
// Update
$user->name = 'Jane Doe';
$user->save();
// Delete
$user->delete();
// Query Builder
$users = User::where('status', 'active')
->where('age', '>', 18)
->orderBy('name')
->limit(10)
->get();DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=my_app
DB_USERNAME=root
DB_PASSWORD=passwordDB_DRIVER=postgresql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=my_app
DB_USERNAME=postgres
DB_PASSWORD=passwordDB_DRIVER=mongodb
DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=my_appDB_DRIVER=sqlite
DB_DATABASE=storage/database/database.sqlite# Start development server
php apna serve
# Create new model
php apna make:model Post
# Create new route
php apna make:route products
# Create new middleware
php apna make:middleware AuthMiddleware
# Create new migration
php apna make:migration create_posts_table
# List all routes
php apna routes
# Show version
php apna --version<?php
return [
'name' => env('APP_NAME', 'ApnaPHP Application'),
'env' => env('APP_ENV', 'production'),
'debug' => env('APP_DEBUG', false),
'url' => env('APP_URL', 'http://localhost'),
'timezone' => env('APP_TIMEZONE', 'UTC'),
];<?php
return [
'default' => env('DB_DRIVER', 'mysql'),
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 3306),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
],
// ... other connections
],
];We appreciate your interest! However, please note:
- β You can use this framework to build applications
- β You can report bugs and issues
- β You can suggest features
- β Direct modifications to the framework core are not accepted
- β Derivative works of the framework are not permitted
For feature requests and bug reports, please open an issue on GitHub.
This project is licensed under the MIT License with additional restrictions - see the LICENSE file for details.
Important: You may use this framework to build applications, but you are NOT permitted to modify, alter, or create derivative works of the framework itself without explicit written permission.
- Inspired by Next.js App Router
- Inspired by Laravel
- Built with modern PHP features
- π§ Email: support@alsocoder.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: docs.apnaphp.com
Made with β€οΈ by Also Coder (Dinesh Gupta)
Β© 2025 Also Coder. All rights reserved.
