mhvefgh / microlite
A modern, lightweight, PSR-15 compliant PHP microframework with zero bloat.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:project
pkg:composer/mhvefgh/microlite
Requires
- php: >=8.1
- catfan/medoo: ^2.1
- guzzlehttp/guzzle: ^7.9
- laminas/laminas-diactoros: ^3.8
- nesbot/carbon: ^3.8
- nikic/fast-route: ^1.3
- predis/predis: ^2.2
- symfony/console: ^7.2
- symfony/process: ^7.2
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- phpunit/phpunit: ^10.5
- symfony/var-dumper: ^7.1
README
Microlite
A fast, lightweight, modern PHP microframework inspired by Laravel β fully PSR-15 compliant.
Build APIs, microservices, or small apps with zero bloat. Simple, speedy, and scalable.
About
Microlite is a modern, ultra-lightweight PHP microframework built for developers who want simplicity, speed, and complete control over their application architecture. Designed for projects where a full-stack framework is unnecessary or too heavy, Microlite provides the essential tools you need β and nothing you donβt.
Inspired by the elegance and developer-friendly structure of Laravel, Microlite offers a familiar and intuitive workflow without requiring you to learn a new ecosystem. If you enjoy the Laravel style but need something significantly smaller and faster, Microlite is the perfect fit.
Fully PSR-15 compliant, minimal by design, and highly flexible, Microlite allows you to extend or customize every layer. Whether you're building micro-services, APIs, or small high-performance applications, Microlite keeps your stack clean and efficient.
Contributions are welcome β feel free to star the project, open issues, or submit PRs! π
Why Microlite?
| Feature | Microlite | Laravel | Slim |
|---|---|---|---|
| Size | ~50KB | ~10MB+ | ~100KB |
| Speed | Ultra-fast | Medium | Fast |
| Learning Curve | Laravel-like | High | Low |
| Dependencies | Zero bloat | Many | Minimal |
| Best For | APIs & Microservices | Full apps | APIs |
Perfect when you love Laravel's style but hate the overhead.
Features
- Zero Bloat β Only what you need
- FastRoute β Blazing fast routing
- Medoo ORM β Lightweight database layer
- PSR-15 Middleware β Full stack support
- .env Config β Simple environment management
- CLI Tools β Symfony Console commands
- PHP Views β With helpers (
view(),e(),auth()) - Session Auth β Built-in authentication helper
- Testing Ready β PHPUnit + examples
Installation
composer create-project mhvefgh/microlite my-app
cd my-app
cp .env.example .env
php -S localhost:8000 -t public
Open β http://localhost:8000
Quick Start
1. Routes (routes/web.php)
<?php return function ($app) { $router = $app->router(); $router->get('/', 'HomeController@index'); $router->get('/hello/{name}', 'HomeController@hello'); $router->get('/dashboard', 'DashboardController@index')->middleware('auth'); };
2. Controller (app/Controllers/HomeController.php)
<?php namespace App\Controllers; use Src\Core\Controller; use Src\Core\Request; class HomeController extends Controller { public function index(Request $req): string { return view('home', [ 'title' => 'Welcome to Microlite', 'user' => auth() ], 'layouts.main'); } public function hello(Request $req, string $name): string { return "<h1>Hello, " . e($name) . "!</h1>"; } }
3. View (resources/views/home.php)
<h1 class="text-4xl font-bold"><?= $title ?></h1> <p>Welcome to Microlite! <?= auth() ? 'Logged in as ' . e(auth()->name) : 'Guest' ?></p> <a href="/hello/World" class="text-blue-600 underline">Say Hello β</a>
Database & Model Example
// app/Models/User.php <?php namespace App\Models; use Src\Core\Model; class User extends Model { protected string $table = 'users'; protected array $fillable = ['name', 'email', 'password']; public function save(): bool { if ($this->password) { $this->password = password_hash($this->password, PASSWORD_DEFAULT); } return parent::save(); } } // In controller $user = new User([ 'name' => 'Ali', 'email' => 'ali@example.com', 'password' => '123456' ]); $user->save();
Middleware Example
// app/Middleware/AuthMiddleware.php <?php namespace App\Middleware; use Src\Core\Middleware; use Src\Core\Request; class AuthMiddleware extends Middleware { public function handle(Request $request, callable $next) { if (!auth()) redirect('/login'); return $next($request); } }
Project Structure
my-app/
βββ app/ # Controllers, Models, Middleware
βββ public/ # index.php (entry point)
βββ resources/views/ # PHP templates
βββ routes/ # web.php
βββ src/ # Framework core
βββ tests/ # PHPUnit tests
βββ .env.example
βββ composer.json
CLI Commands
# Show Microlite information (default command) php microlite php microlite about # Start the development server (like php artisan serve) php microlite serve php microlite serve --host=0.0.0.0 --port=8080 # Generate a new controller php microlite make:controller UserController php microlite make:controller Admin/PostController # Generate a new model php microlite make:model Post php microlite make:model ProductCategory # Clear application cache php microlite cache:clear # Get help for any command php microlite --help php microlite serve --help
Available Commands
| Command | Description |
|---|---|
about |
Display Microlite version and environment info |
serve |
Start the built-in PHP development server |
make:controller <name> |
Create a new controller class |
make:model <name> |
Create a new model class |
cache:clear |
Remove all cached files (views, config, routes, etc.) |
Tip: Just run php microlite with no arguments to see the beautiful welcome screen!
Testing
composer test
Contributing
We love contributions!
Fork β Create branch β Commit β Push β Pull Request
Author
Mohammad Hossein Vefgh
Full-Stack PHP Developer | Open Source Enthusiast
- GitHub: @mhvefgh
- Email: vefgh.m.hossein@gmail.com
- LinkedIn: Mohammad Hossein Vefgh
License
Released under the MIT License.
Copyright Β© 2025 Mohammad Hossein Vefgh
If you like Microlite, give it a β
Microlite β Laravel-style, but microlite.