Zero Framework is a native-PHP micro-framework that mirrors the developer ergonomics of Laravel while avoiding external runtime dependencies. It keeps the stack lean, embraces expressive APIs for routing, HTTP handling, templating, and data access, and ships with a tiny CLI to cover the common workflows you expect from a modern framework.
- Highlights
- Requirements
- Installation
- Quick Start
- Project Layout
- Core Concepts
- CLI Reference
- Configuration
- Deployment
- Documentation
- Roadmap
- Inspiration
- Contributing
- License
- Laravel-inspired developer experience with native PHP under the hood.
- Productive router with groups, middleware pipelines, and auto dependency injection.
- First-class HTTP abstractions: rich request helpers and flexible response factories.
- Blade-style view engine with layouts, sections, directives, and optional caching.
- Fluent DBML (Database Management Layer) query builder, active-record models, migrations, and seeders driven by a concise DBAL.
- Battery-included CLI (
zero) for serving, scaffolding, and database management. - SMTP mailer with fluent message composition and secure TLS defaults.
- Centralised error handler with configurable HTML/JSON output and configurable log channels (file or database).
- Simple
.envloader with support for multiple environments and interpolation.
- PHP 8.1 or newer with the
pdoextension (SQLite, MySQL, or PostgreSQL driver). - Optional:
pcntlextension for the--watchdevelopment server flag. - Write access to the
storage/directory for cache, logs, and compiled views. - Composer is not required—the framework ships with its own autoloader.
Get started with Zero Framework using this one-liner (replace my-project with your desired project name):
curl -L -o main.zip https://zerophp.com/get/latest.zip \
&& unzip -q main.zip \
&& rm main.zip \
&& mv Zero-main my-project \
&& cd my-project \
&& rm -rf docs todo.md readme.md .git \
&& cp .env.example .env \
&& php zero key:generateInvoke-WebRequest -Uri "https://zerophp.com/get/latest.zip" -OutFile "main.zip";
Expand-Archive -Path "main.zip" -DestinationPath "." -Force;
Remove-Item "main.zip";
Rename-Item "Zero-main" "my-project";
Set-Location "my-project";
Remove-Item -Recurse -Force docs, todo.md, readme.md;
Copy-Item ".env.example" ".env"
php zero key:generate- The installation script will create a new project and generate an application key.
- Copy
.env.exampleto.envand adjust host/port or database credentials as needed. - Ensure the
storage/directory is writable (chmod -R 775 storage). - Serve the application:
Add
php zero serve --host=127.0.0.1 --port=8000 --root=public
--watchto restart automatically on file changes, or try--franken/--swoleefor experimental backends. - Visit the configured host/port to see the starter page.
Run migrations or seeders whenever you update the database schema:
php zero migrate
php zero db:seed Database\\Seeders\\DatabaseSeederapp/ # Controllers, middlewares, and models for your application
config/ # Framework configuration (database, storage, view, etc.)
core/ # Framework libraries, bootstrap files, and infrastructure
database/ # Migrations and seeders
docs/ # In-depth documentation for each subsystem
public/ # HTTP entry point (`index.php`) and public assets
resources/ # View templates, layouts, and components
routes/ # Route definitions (`web.php`)
storage/ # Cache, compiled views, and runtime state
zero # CLI entry point for serving and scaffolding
- Define HTTP verbs and controller actions in
routes/web.phpusingZero\Lib\Routerhelpers (get,post,put, etc.). - Group routes with shared prefixes or middleware; nested groups compose cleanly.
- Path parameters are type-hinted and injected automatically, along with the shared
Requestinstance. - Middleware can short-circuit by returning a response, ideal for guard logic.
Zero\Lib\Http\Request::capture()snapshots query, form, JSON, file, and header data, exposing helpers likeinput,json,header,ip, andexpectsJson.- Middleware can cache work for later using request attributes:
Request::set('key', $value)in middleware andRequest::get('key')(orRequest::instance()->key) in controllers. - Controllers may return strings, arrays, models, iterables, or explicit
Responseobjects; the router normalises everything throughZero\Lib\Response::resolve(). - Response factories cover HTML, JSON, text, redirects, streams, and opinionated API envelopes.
Zero\Lib\View::render('pages/home', $data)compiles Blade-inspired templates with layout, section, include, and directive support.Zero\Lib\View::renderString($template, $data)renders a Blade-style template string when you already have the markup in memory.- Toggle view caching via
config/view.phporView::configure(). Compiled templates live understorage/cache/views. - Global
view()andresponse()helpers simplify controller return values.
Zero\Lib\DB\DBML(the Database Management Layer) provides fluent query building with selections, joins, aggregates, pagination, and safe bindings.- Run migrations with
php zero migrate; create new migrations viaphp zero make:migration create_posts_tableand describe schema using the migration DBAL (Zero\Lib\DB\Schema). - Seeders extend
Zero\Lib\DB\Seederand execute withphp zero db:seed.
- Extend
Zero\Lib\Modelfor active-record style classes with fillable attributes, timestamps, and lazy relationships (hasOne,hasMany,belongsTo). - Chainable query builder methods return hydrated model instances; use
paginate()orsimplePaginate()for pagination. - Call
toBase()when you need the underlying DBML builder for complex queries.
App\Controllers\Auth\AuthControllerhandles login/logout and refuses access until the account is email verified.App\Controllers\Auth\RegisterController,App\Controllers\Auth\EmailVerificationController, andApp\Controllers\Auth\PasswordResetControllerprovide Laravel-style registration, verification, and password reset flows out of the box.- Outbound mail (verification/reset links) is rendered with Blade-style views and delivered through the built-in SMTP mailer.
- Protect routes with
App\Middlewares\Auth; unauthenticated requests are redirected to/loginwith the intended URL stored in the session. - Access the current user via the
Authfacade (Auth::user(),Auth::id()), or extend the controllers to suit domain-specific policies.
core/kernel.phpregisters lightweight facades (View,DB,Model,DBML,Auth,Mail) and autoloaded helper files.- Use the global
config()helper for dot-access toconfig/*.php, andenv()for values from.env,.env.staging, or.env.production(later files override earlier ones and support${VAR}interpolation).
Zero\Lib\Http\Httpprovides a fluent HTTP client for outbound requests (JSON helpers, timeouts, retries, file uploads).Zero\Lib\Support\Strbundles familiar string transformations (studly, camel, snake, slug, etc.) for CLI and application code.Zero\Lib\Storage\Storagepersists files to the configured disks; pair with uploaded files via$file->store().
| Command | Description |
|---|---|
php zero serve [--host] [--port] [--root] [--watch] [--franken] [--swolee] |
Run the development server (with optional file watching or alternative backends). |
php zero make:controller Name [--force] |
Generate a controller scaffold under app/controllers. |
php zero log:clear [--channel] [--path] |
Delete generated *.log files for the chosen log channel or directory. |
php zero db:dump [--connection] [--file] |
Export the configured database to an SQL dump file. |
php zero db:restore [--connection] [--file] |
Restore the configured database from an SQL dump file. |
php zero make:service Name [--force] |
Generate a service class in app/services. |
php zero make:model Name [--force] |
Generate an active-record model in app/models. |
php zero make:migration Name [--force] |
Create a timestamped migration in database/migrations. |
php zero migrate |
Apply outstanding migrations. |
php zero migrate:rollback [steps] |
Roll back the latest migration batches. |
php zero migrate:refresh |
Roll back every migration batch, then rerun them. |
php zero migrate:fresh |
Drop all tables and execute migrations from scratch. |
php zero make:seeder Name [--force] |
Generate a seeder class in database/seeders. |
php zero db:seed [FQN] |
Run a seeder (defaults to Database\\Seeders\\DatabaseSeeder). |
php zero storage:link |
Create symbolic links for configured storage disks. |
- Environment variables are loaded in priority order:
.env→.env.staging→.env.production, with${VAR}interpolation and array syntax[a,b,c]support. - Database connections live in
config/database.phpwith drivers for MySQL, PostgreSQL, and SQLite. Switch drivers viaDB_CONNECTIONor driver-specific env vars (MYSQL_HOST,SQLITE_DATABASE, etc.). - Sessions default to the database driver via
config/session.php; adjust lifetime, cookie name, or switch to encrypted cookie storage withSESSION_DRIVER=cookie. - Authentication tokens default to a one-week TTL; set
AUTH_TOKEN_TTL(seconds) in.envorconfig/auth.phpif you need different longevity. - Logging is defined in
config/logging.php. Switch between file and database channels withLOG_DRIVER, and point the database channel at a custom table viaLOG_TABLE. - File storage defaults to the
publicdisk (local); configure S3 via the news3disk when needed; adjustconfig/storage.phpor.env(STORAGE_DISK,STORAGE_PUBLIC_ROOT,STORAGE_PRIVATE_ROOT) and persist uploads withStorage::put()/$file->store(). - Updater settings live in
config/update.php. SetUPDATE_MANIFEST_URL(and optionalUPDATE_TIMEOUT) to enable theupdate:latestcommand.- Leave
UPDATE_MANIFEST_URLblank to pull the latest GitHub release (or branch) usingUPDATE_GITHUB_REPOandUPDATE_GITHUB_BRANCH.
- Leave
- Update
config/view.php,config/storage.php, and other config files to match your deployment needs.
For a production-ready setup (Nginx + PHP-FPM, environment variables, logging, migrations), see the dedicated deployment guide. It covers server requirements, TLS, cron tasks, and the configurable logging channels.
- Framework Overview
- Request & Response Lifecycle
- Routing
- DBML Query Builder
- Model Layer
- View Layer
- Authentication
- Mailer
- CLI Tooling
- Storage
Active ideas and upcoming improvements live in todo.md. Highlights include CSRF protection, richer CLI command dispatching, eager-loading helpers, and a centralised exception handler.
This project draws inspiration from Laravel's elegance while celebrating the simplicity of native PHP—clean, self-sufficient code with a modern developer experience.
- Fork the repository and create a feature branch.
- Make your changes with clear commits and matching documentation updates.
- Open a pull request describing the motivation and testing notes.
Bug reports and feature requests are welcome—open an issue or start a discussion.
A license file has not been published yet. Add your preferred license at the repository root to clarify usage terms.