https://github.com/baremetalphp/baremetalphp
https://github.com/baremetalphp/baremetalphp
baremetalphp framework php
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/baremetalphp/baremetalphp
- Owner: baremetalphp
- Created: 2025-12-06T19:56:35.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-12-08T21:29:47.000Z (4 months ago)
- Last Synced: 2025-12-11T12:24:54.367Z (4 months ago)
- Topics: baremetalphp, framework, php
- Language: PHP
- Homepage: https://baremetalphp.com
- Size: 29.3 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Bare Metal PHP
### A modern PHP framework with a Go-powered application server
BareMetalPHP is a lightweight, high-performance PHP framework designed around a simple idea:
**PHP should run fast by default β without FPM, without heavy stacks, and without hacks.**
Instead of relying on traditional PHP-FPM, BareMetalPHP includes an optional **Go application server** that manages persistent PHP workers. This provides:
- Huge performance gains over cold-start PHP
- True parallelism (fast + slow worker pools)
- Zero-config hot reload
- Static asset offloading
- A fast, modern DX similar to Node, Go, or Rust
If you want Laravelβs experience but not Laravelβs overhead, this is your framework.
---
## β¨ Key Features
### π¨ 1. Go-Powered App Server (the BareMetal Runtime)
BareMetalPHP includes a Go runtime that functions like a lightweight alternative to Swoole or Laravel Octane:
- Persistent PHP worker pool
- Fast + slow request classification
- Hot reload for PHP & routes
- Static file serving
- Efficient GoβPHP bridge protocol
Enable it with:
```env
APPSERVER_ENABLED=true
```
Start it with:
```bash
php mini go:serve
```
Dry run:
```bash
php mini go:serve --dry-run
```
### π― 2. A modern, minimal PHP framework
BareMetalPHP provides:
- Simple router
- Controller + method resolution
- PSR-7-style Request & Response
- Lightweight dependency injection container
- View layer
- Migrations + SQLite testing utilities
- `mini` CLI (generators, migrations, test tools)
It is intentionally small, readable, and fast.
### βοΈ 3. Fully tested
The framework is covered by a deterministic test suite:
- Routing, container, HTTP kernel
- Database + migrations + rollback
- Go app server installer
- Go -> PHP worker bridge
Run all tests:
```bash
vendor/bin/phpunit
```
### π§° Installation
Create a new BareMetalPHP project:
```bash
composer create-project baremetalphp/baremetalphp my-app
cd my-app
```
Run the built-in PHP server:
```bash
php mini serve
```
#### Install the Go application server
```bash
php mini go:install
go mod tidy
php mini go:serve
```
Default Go server URL:
```bash
http://localhost:8080
```
### βοΈ Configuration `(config/appserver.php)`
```php
return [
'enabled' => env('APPSERVER_ENABLED', false),
'fast_workers' => (int) env('APPSERVER_FAST_WORKERS', 4),
'slow_workers' => (int) env('APPSERVER_SLOW_WORKERS', 2),
'hot_reload' => (bool) env('APPSERVER_HOT_RELOAD', true),
'static' => [
['prefix' => '/assets/', 'dir' => 'public/assets'],
['prefix' => '/build/', 'dir' => 'public/build'],
['prefix' => '/css/', 'dir' => 'public/css'],
['prefix' => '/js/', 'dir' => 'public/js'],
['prefix' => '/images/', 'dir' => 'public/images'],
['prefix' => '/img/', 'dir' => 'public/img'],
],
];
```
The Go installer generates a matching `go_appserver.json` automatically.
### π§© Architecture Overview
```arduino
ββββββββββββββββββββββββββββββββ
β Go HTTP Server β
β - static files β
Request ββββββΆβ - routing fallback ββββββββββββ
β - hot reload watcher β β
ββββββββββββββββββββββββββββββββ β
βΌ
ββββββββββββββββββββββββββββ
β PHP Worker Pool β
β (persistent processes) β
ββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββ
β BareMetalPHP Framework β
β - routing β
β - container β
β - controllers β
β - views β
β - database/migrations β
ββββββββββββββββββββββββββββ
```
### π¦ Commands
```bash
php mini serve
php mini make:controller Foo
php mini make:migration create_users
php mini migrate
php mini migrate:rollback
php mini install:go-appserver
php mini go:serve
php mini go:serve --dry-run
```
### π Version 0.2.0 Release Notes
- Go application server is now a first-class feature
- `go:serve` command added
- `go:install` scaffolding generator added
- `go_appserver.json` generated from PHP config
- Persistent PHP worker bridge implemented
- Better migration rollback logic
- Higher overall test coverage
### π£ Roadmap
- Zero-downtime worker recycling
- WebSockets via Go
- Cache subsystem
- Async jobs via Go sidecar
- API rate limiting
- Events + Subscribers
- Optional queue runner
### π€ Contributing
Contributions, ideas, and issues are welcome.
### π License
MIT