arkham-dev / framework
A lightweight, modern PHP framework built from scratch with MVC architecture, database wizard, and powerful developer tools
Package info
github.com/JosueIsOffline/Arkham
Language:Twig
Type:project
pkg:composer/arkham-dev/framework
Requires
- php: >=8.1
- ext-json: *
- ext-pdo: *
- nikic/fast-route: ^1.3
- twig/twig: ^3.21
Requires (Dev)
- phpunit/phpunit: ^12.2
This package is auto-updated.
Last update: 2026-04-25 18:16:44 UTC
README
Arkham is a lightweight, modern PHP framework built from scratch following MVC architecture principles. It provides developers with essential tools for rapid web application development while maintaining simplicity and performance.
π Features
- MVC Architecture: Clean separation of concerns with Models, Views, and Controllers
- Database Wizard: Interactive setup wizard for database configuration and table creation
- Query Builder: Intuitive fluent interface for database operations
- Twig Integration: Powerful templating engine for dynamic views
- Fast Routing: High-performance routing system powered by FastRoute
- Multiple Database Support: MySQL, PostgreSQL, SQLite, and SQL Server
- Auto-Setup: Automatic framework initialization and configuration
- PHPUnit Testing: Built-in testing framework support
- Composer Ready: PSR-4 autoloading and Composer integration
π Requirements
- PHP 8.1 or higher
- Composer
- Web server (Apache, Nginx, or built-in PHP server)
- Database server (optional - SQLite works out of the box)
π§ Installation
Via Composer (Recommended)
(recommended)
composer init
composer require arkham-dev/framework
or
composer create-project arkham-dev/framework my-app
cd my-app
php -S localhost:8000 -t public
Manual Installation
git clone https://github.com/JosueIsOffline/Arkham.git my-app
cd my-app
composer install
php -S localhost:8000 -t public
π Quick Start
1. Initial Setup
When you first visit your application, Arkham will automatically redirect you to the Database Setup Wizard:
http://localhost:8000
The wizard will guide you through:
- Database connection configuration
- Database creation
- Table and field setup
- Configuration file generation
2. Create Your First Controller
<?php namespace App\Controllers; use JosueIsOffline\Framework\Controllers\AbstractController; use JosueIsOffline\Framework\Http\Response; class WelcomeController extends AbstractController { public function index(): Response { return $this->render('welcome.html.twig', [ 'message' => 'Hello from Arkham!' ]); } }
3. Define Routes
Edit routes/web.php:
<?php use App\Controllers\WelcomeController; return [ ['GET', '/', [WelcomeController::class, 'index']], ['GET', '/welcome/{name}', [WelcomeController::class, 'show']], ['POST', '/api/users', [UserController::class, 'store']], ];
4. Create Views
Create views/welcome.html.twig:
{% extends "base.html.twig" %}
{% block title %}Welcome to Arkham{% endblock %}
{% block content %}
<div class="container">
<h1>{{ message }}</h1>
<p>Welcome to the Arkham PHP Framework!</p>
</div>
{% endblock %}
ποΈ Database Operations
Using the Query Builder
use JosueIsOffline\Framework\Database\DB; // Select all users $users = DB::table('users')->select()->get(); // Find a specific user $user = DB::table('users')->where('id', 1)->first(); // Insert a new user DB::table('users')->insert([ 'name' => 'John Doe', 'email' => 'john@example.com' ]); // Update user DB::table('users') ->where('id', 1) ->update(['name' => 'Jane Doe']); // Delete user DB::table('users')->where('id', 1)->delete();
Using Models
<?php namespace App\Models; use JosueIsOffline\Framework\Model\Model; class User extends Model { protected string $table = 'users'; protected array $fillable = ['name', 'email', 'password']; } // Usage $users = User::all(); $user = User::find(1); $activeUsers = User::where('status', 'active');
π Directory Structure
my-app/
βββ app/
β βββ Controllers/
β β βββ HomeController.php
β β βββ BookController.php
β βββ Models/
βββ config/
β βββ database.json (auto-generated)
βββ public/
β βββ index.php
βββ routes/
β βββ web.php
βββ src/
β βββ Controllers/
β βββ Database/
β βββ Http/
β βββ Model/
β βββ Routing/
β βββ View/
βββ tests/
βββ views/
β βββ base.html.twig
β βββ home.html.twig
β βββ book.html.twig
βββ composer.json
βββ README.md
π― Advanced Features
Custom Middleware
<?php namespace App\Middleware; use JosueIsOffline\Framework\Http\Request; use JosueIsOffline\Framework\Http\Response; class AuthMiddleware { public function handle(Request $request, callable $next): Response { // Authentication logic here if (!$this->isAuthenticated($request)) { return new Response('Unauthorized', 401); } return $next($request); } }
Database Configuration
The framework supports multiple database drivers:
{
"driver": "mysql",
"host": "localhost",
"port": 3306,
"database": "my_app",
"username": "root",
"password": "secret",
"charset": "utf8mb4",
"collation": "utf8mb4_unicode_ci"
}
View Helpers
// In your controller public function show(): Response { return $this->render('user/profile.html.twig', [ 'user' => $user, 'posts' => $posts ]); }
π§ͺ Testing
Run the test suite:
composer test
Example test:
<?php use PHPUnit\Framework\TestCase; use JosueIsOffline\Framework\Database\QueryBuilder; class QueryBuilderTest extends TestCase { public function testSelectQuery() { $qb = new QueryBuilder($this->connection); $sql = $qb->table('users')->select('name', 'email')->toSql(); $this->assertEquals('SELECT name, email FROM users', $sql); } }
π Documentation
Core Components
- Kernel: The heart of the framework, handles HTTP requests
- Router: Fast and flexible routing system
- Controllers: Handle business logic and return responses
- Models: Interact with database using Query Builder
- Views: Twig-powered templating system
- Database: Multi-driver database abstraction layer
Configuration
The framework automatically generates configuration files during setup. Manual configuration is also supported:
// Bootstrap database connection use JosueIsOffline\Framework\Database\DB; DB::configure([ 'driver' => 'sqlite', 'database' => 'database/app.sqlite' ]);
π€ Contributing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
git clone https://github.com/arkham/framework.git cd framework composer install composer test
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- FastRoute by Nikita Popov for routing
- Twig by Fabien Potencier for templating
- PHPUnit for testing framework
- The PHP community for inspiration and best practices
π Support
- Documentation: https://arkham-framework.dev
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@arkham-framework.dev
πΊοΈ Roadmap
- Session management
- Authentication system
- Cache layer
- CLI commands
- Migration system
- Event system
- API documentation generator
- Performance optimization tools
Arkham Framework - Building the future of PHP web development, one commit at a time.
Made with β€οΈ by the Arkham Team