Zap
PHP framework

Build modern apps with Zap.

Zap is a lightweight PHP framework for route-first development, simple controllers, reusable Blade templates, and a clean asset workflow that keeps your app fast and easy to maintain.

  • Fast Route-first
  • Simple Blade views
  • Secure CSRF + sessions
<?php

use Zap\Core\Http\Route;

Route::get('/', 'HomeController@index')->name('home.index');
Route::get('/docs/{slug}', 'DocsController@show')
 ->whereAlphaNumeric('slug');

return $this->view('pages.home.index', [
 'title' => 'Zap PHP Framework',
]);
Ready to ship

Overview

Zap gives you a straightforward MVC-like architecture without overwhelming ceremony. Define routes, map them to controllers, render Blade templates, and keep your front-end assets organized with Vite.

It is intentionally lightweight, ideal for internal tools, dashboards, APIs, and product landing pages that need a clean framework foundation without a heavy runtime.

<?php

namespace Zap\App\Controllers;

use Zap\Core\Base\BaseController;

class HomeController extends BaseController
{
 public function index()
 {
 return $this->view('pages.home.index', [
 'title' => 'Zap PHP Framework',
 ]);
 }
}

Quick start

Install dependencies and start building immediately. Zap already includes the core framework pieces, session support, asset helpers, and a route-driven app bootstrapping flow.

composer install
cp .env.example .env
php -S localhost:8000 dev-server.php

Install

Use Composer to install the framework runtime and dependencies.

Configure

Populate your environment and app configuration for local or production usage.

Run

Boot the app with the built-in PHP development server or your chosen host.

Routing

Routes are registered centrally and mapped to controller actions. This keeps the application flow easy to trace and simple to organize.

<?php

use Zap\Core\Http\Route;
use Zap\Core\Http\Router;

return static function (Router $router): void {
 Route::get('/', 'HomeController@index')->name('home.index');
 Route::get('/docs/{slug}', 'DocsController@show')->whereAlphaNumeric('slug');
 Route::post('/contact', 'ContactController@store');
};
  • Route names make URL generation and link generation simple.
  • Route constraints keep dynamic segments safe and predictable.
  • Middleware can enforce auth, validation, or request checks.
Read the routing guide

Views and BladeOne

Build pages with BladeOne templates, shared layouts, sections, and partials. Keep presentation in dedicated view files and pass the data they need from controller actions.

Read the Views guide

Security

Zap already includes session handling and a security helper for CSRF validation and data sanitization. Use them as the foundation for a safer application layer.

$security = service('\Zap\Core\Utils\Security');
$token = $security->generate_token();

if (! $security->validate_request(true)) {
 throw new RuntimeException('Invalid CSRF token.');
}
  • Store a strong APP_KEY for encrypted session and cookie handling.
  • Use HTTPS in production and protect state-changing routes with CSRF.
  • Validate request input before writing to the database or rendering content.

Assets and frontend

Zap supports Vite and ships with frontend assets for Litewire, Flasher, and DataGrid. This gives you a lightweight backend with useful UI tools when you need them.

import '../css/app.css';

console.info('Zap Vite entry loaded.');
  • Use `resources/js/app.js` for shared frontend logic.
  • Use `resources/css/app.css` for projectwide design and utilities.
  • Activate Litewire, Flasher, and DataGrid when your UI needs reactivity or data tables.
Read the assets guide