PHPackages                             lalaz/framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lalaz/framework

ActiveLibrary[Framework](/categories/framework)

lalaz/framework
===============

The Lalaz PHP Framework

v1.0.0-rc.2(5mo ago)042MITPHPPHP ^8.3

Since Dec 15Pushed 5mo agoCompare

[ Source](https://github.com/lalaz-foundation/framework)[ Packagist](https://packagist.org/packages/lalaz/framework)[ RSS](/packages/lalaz-framework/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (2)

 [![Lalaz Framework](https://raw.githubusercontent.com/lalaz-foundation/art/main/packages/framework-logo.svg)](https://raw.githubusercontent.com/lalaz-foundation/art/main/packages/framework-logo.svg)

Lalaz Framework
===============

[](#lalaz-framework)

 **The foundation that powers everything.**

 [![PHP Version](https://camo.githubusercontent.com/62c818c7128b9795d42cb7acbb1fc38fbed88d0b153c2a8ef8e1054745a4ea5c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net) [![License](https://camo.githubusercontent.com/422db9fd40f5831c765cf6530b6750c081b696bd18d904cf89554df98c676277/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666c61742d737175617265)](LICENSE) [![Version](https://camo.githubusercontent.com/ea9ef426d7257249967444fc38f23d854e483b614a19030e12feb17fa0bb5ff5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c75653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lalaz/framework) [![Tests](https://camo.githubusercontent.com/055a10ea5e9d7b2da16c59c016728f2177670bc236cc06be2b301c6ddb95c868/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d35383425323070617373696e672d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://github.com/lalaz-foundation/framework/actions)

 [Quick Start](#-quick-start) • [Features](#-features) • [Documentation](#-documentation) • [Examples](#-examples) • [Contributing](#-contributing)

---

What is Lalaz Framework?
------------------------

[](#what-is-lalaz-framework)

Lalaz Framework is the **core runtime** for the Lalaz PHP Framework. It provides dependency injection, HTTP handling, routing, configuration, logging, and CLI infrastructure—everything you need to build modern PHP applications.

```
// Define a route with dependency injection
$router->get('/users/{id}', function (Request $request, Response $response, UserService $service) {
    $user = $service->find($request->routeParam('id'));
    $response->json($user);
});
```

---

⚡ Quick Start
-------------

[](#-quick-start)

### Installation

[](#installation)

```
composer require lalaz/framework
```

### 1. Create Your First Route (30 seconds)

[](#1-create-your-first-route-30-seconds)

```
use Lalaz\Web\Routing\Router;
use Lalaz\Web\Http\Request;
use Lalaz\Web\Http\Response;

$router = new Router();

$router->get('/', function (Request $request, Response $response) {
    $response->json(['message' => 'Hello, Lalaz!']);
});

$router->get('/users/{id}', function (Request $request, Response $response) {
    $id = $request->routeParam('id');
    $response->json(['user' => ['id' => $id]]);
});
```

### 2. Use Dependency Injection

[](#2-use-dependency-injection)

```
use Lalaz\Container\Container;

$container = new Container();

// Register services
$container->singleton(UserService::class);
$container->bind(CacheInterface::class, RedisCache::class);

// Auto-wiring resolves dependencies automatically
$userService = $container->resolve(UserService::class);
```

### 3. Access Configuration

[](#3-access-configuration)

```
use Lalaz\Config\Config;

Config::load(__DIR__ . '/.env');

$debug = Config::getBool('app.debug', false);
$dbHost = Config::getString('database.host', 'localhost');
```

**That's the basics!** For advanced routing, middleware, and more, keep reading.

---

✨ Features
----------

[](#-features)

### 🏗️ Dependency Injection

[](#️-dependency-injection)

PSR-11 compliant container with auto-wiring, scoped bindings, and method injection.

### 🚀 High-Performance Routing

[](#-high-performance-routing)

Attribute-based routing, groups, middleware, and URL generation.

### 📝 Configuration

[](#-configuration)

Environment-aware config with caching, typed getters, and dot notation.

### 📊 PSR-3 Logging

[](#-psr-3-logging)

Multi-channel logging with rotating files, formatters, and custom writers.

### 💻 CLI Framework

[](#-cli-framework)

Command infrastructure with dependency injection and code generators.

### 🛡️ Resilience Patterns

[](#️-resilience-patterns)

Circuit breaker and retry patterns for fault-tolerant applications.

---

📖 Examples
----------

[](#-examples)

### HTTP Request Handling

[](#http-request-handling)

```
use Lalaz\Web\Http\Request;

$request = Request::fromGlobals();

// Access request data
$id = $request->routeParam('id');
$page = $request->queryParam('page', 1);
$name = $request->input('name');

// JSON body
$data = $request->json();

// Content negotiation
if ($request->wantsJson()) {
    // Return JSON response
}
```

### HTTP Response Building

[](#http-response-building)

```
use Lalaz\Web\Http\Response;

$response = new Response($_SERVER['HTTP_HOST']);

// JSON response
$response->json(['success' => true], 200);

// Redirect
$response->redirect('/dashboard');

// File download with streaming
$response->download('/path/to/file.pdf', 'report.pdf');

// Streaming response
$response->stream(function ($write) use ($data) {
    foreach ($data as $chunk) {
        $write(json_encode($chunk) . "\n");
    }
});
```

### Advanced Routing

[](#advanced-routing)

```
use Lalaz\Web\Routing\Router;
use Lalaz\Web\Routing\Attribute\Route;

$router = new Router();

// Route groups with middleware
$router->group([
    'prefix' => '/api/v1',
    'middleware' => [AuthMiddleware::class],
], function ($router) {
    $router->get('/users', [UserController::class, 'index']);
    $router->post('/users', [UserController::class, 'store']);
});

// Resource routes (RESTful)
$router->resource('posts', PostController::class);

// Named routes with URL generation
$router->get('/users/{id}', [UserController::class, 'show'])->name('users.show');
$url = $router->url()->to('users.show', ['id' => 123]); // /users/123
```

### Attribute-Based Routing

[](#attribute-based-routing)

```
use Lalaz\Web\Routing\Attribute\Route;

class UserController
{
    #[Route('GET', '/users')]
    public function index(): void { }

    #[Route('GET', '/users/{id}')]
    public function show(Request $request): void { }

    #[Route(['GET', 'POST'], '/users/search', middleware: [AuthMiddleware::class])]
    public function search(): void { }
}

$router->registerControllers([UserController::class]);
```

### Container &amp; Dependency Injection

[](#container--dependency-injection)

```
use Lalaz\Container\Container;

$container = new Container();

// Singleton binding
$container->singleton(CacheInterface::class, RedisCache::class);

// Scoped binding (per-request)
$container->scoped(RequestContext::class);

// Method injection
$container->when(UserService::class)
    ->needs('setLogger')
    ->give(FileLogger::class);

// Service tagging
$container->tag(FileLogger::class, 'loggers');
$container->tag(DatabaseLogger::class, 'loggers');
$loggers = $container->tagged('loggers');
```

### Circuit Breaker Pattern

[](#circuit-breaker-pattern)

```
use Lalaz\Support\Resilience\CircuitBreaker;

$breaker = CircuitBreaker::create()
    ->withFailureThreshold(5)
    ->withRecoveryTimeout(30)
    ->onTrip(fn ($e, $failures) => Log::error("Circuit tripped: {$failures} failures"))
    ->withFallback(fn () => ['status' => 'degraded']);

$result = $breaker->execute(function () use ($httpClient) {
    return $httpClient->get('/external-api');
});
```

---

🏗️ Architecture
---------------

[](#️-architecture)

```
┌──────────────────────────────────────────────────────────────────┐
│                        Your Application                          │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│  Web Layer       Request → Router → Controller → Response        │
│                                                                  │
├──────────────────────────────────────────────────────────────────┤
│  Container       Dependency Injection & Service Resolution       │
├──────────────────────────────────────────────────────────────────┤
│  Config          Environment & Configuration Management          │
├──────────────────────────────────────────────────────────────────┤
│  Logging         Multi-channel PSR-3 Logging                     │
├──────────────────────────────────────────────────────────────────┤
│  Console         CLI Commands & Code Generation                  │
├──────────────────────────────────────────────────────────────────┤
│  Support         Collections, Resilience, Helpers                │
└──────────────────────────────────────────────────────────────────┘

```

**Key Components:**

- **Container** — PSR-11 DI container with auto-wiring
- **Router** — High-performance HTTP routing with groups and middleware
- **Request/Response** — Full HTTP abstraction with streaming
- **Config** — Environment-aware configuration with caching
- **LogManager** — Multi-channel PSR-3 logging
- **Console** — CLI framework with dependency injection

---

📁 Package Structure
-------------------

[](#-package-structure)

```
src/
├── Config/              # Configuration management
│   ├── Config.php           # Static facade
│   └── ConfigRepository.php # Repository implementation
├── Console/             # CLI infrastructure
│   ├── Application.php      # Console application
│   ├── Input.php            # Input handling
│   ├── Output.php           # Output handling
│   └── Commands/            # Built-in commands
├── Container/           # Dependency injection
│   ├── Container.php        # Main container
│   ├── ContainerScope.php   # Scoped lifecycle
│   └── ServiceProvider.php  # Base provider
├── Logging/             # PSR-3 logging
│   ├── Log.php              # Static facade
│   ├── LogManager.php       # Multi-channel manager
│   └── Logger.php           # Logger implementation
├── Runtime/             # Application runtime
│   └── Application.php      # Global app singleton
├── Support/             # Utilities
│   ├── Collections/         # Collection class
│   └── Resilience/          # Circuit breaker, retry
└── Web/                 # HTTP layer
    ├── Http/                # Request/Response
    └── Routing/             # Router

```

---

📚 Documentation (where to read)
-------------------------------

[](#-documentation-where-to-read)

The canonical framework documentation is published on the site and in this repository under two locations:

- Site docs (recommended, used by the public docs site):

    -
    - Repository path: `/docs/packages/framework`
- Local package docs for quick developer reference (inside this package):

    - `./docs/index.md` (package overview)
    - `./docs/quick-start.md` (quick start)
    - `./docs/api/*` (API reference pages, e.g. `./docs/api/container.md`, `./docs/api/request.md`)

If you previously clicked links that looked like `./docs/http.md` or `./docs/routing.md` — those were reorganized into the `api/` and `concepts/` folders. Use the site docs above (recommended) or browse `./docs/` in this package.

---

🔧 Configuration
---------------

[](#-configuration-1)

### Logging Configuration

[](#logging-configuration)

```
// config/logging.php
return [
    'default' => 'app',
    'channels' => [
        'app' => [
            'driver' => 'daily',
            'path' => 'storage/logs/app.log',
            'level' => 'debug',
            'days' => 14,
        ],
        'security' => [
            'driver' => 'single',
            'path' => 'storage/logs/security.log',
            'level' => 'warning',
        ],
    ],
];
```

### Built-in CLI Commands

[](#built-in-cli-commands)

```
# Configuration
php lalaz config:cache          # Cache configuration
php lalaz config:clear          # Clear configuration cache

# Routes
php lalaz routes:list           # List all routes
php lalaz routes:cache          # Cache routes

# Code Generation
php lalaz craft:controller      # Create a new controller
php lalaz craft:model           # Create a new model
php lalaz craft:middleware      # Create a new middleware
php lalaz craft:command         # Create a new command

# Development
php lalaz serve                 # Start development server
```

---

📋 Requirements
--------------

[](#-requirements)

RequirementVersionPHP^8.3psr/log^3.0psr/container^2.0---

🧪 Testing
---------

[](#-testing)

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Run specific test suite
./vendor/bin/phpunit --testsuite=Unit
./vendor/bin/phpunit --testsuite=Integration
```

---

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Here's how you can help:

1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. **Open** a Pull Request

Please read our [Contributing Guide](../../CONTRIBUTING.md) for details on our code of conduct and development process.

---

🔒 Security
----------

[](#-security)

If you discover a security vulnerability, please **do not** open a public issue. Instead, email us at:

📧 ****

We take security seriously and will respond promptly to verified vulnerabilities.

---

📄 License
---------

[](#-license)

Lalaz Framework is open-source software licensed under the [MIT License](LICENSE).

---

 Built with ❤️ by the [Lalaz Foundation](https://github.com/lalaz-foundation)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance72

Regular maintenance activity

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1656ce2106f240db55a76bb5213ef5da4007532661adf4ef89e44eefe7e79112?d=identicon)[lalaz](/maintainers/lalaz)

---

Top Contributors

[![gregserrao](https://avatars.githubusercontent.com/u/1245169?v=4)](https://github.com/gregserrao "gregserrao (1 commits)")

---

Tags

phpframeworklalaz

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lalaz-framework/health.svg)

```
[![Health](https://phpackages.com/badges/lalaz-framework/health.svg)](https://phpackages.com/packages/lalaz-framework)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[phalcon/phalcon

Phalcon Framework

2421.5k1](/packages/phalcon-phalcon)[nimbly/syndicate

A powerful queue and pubsub message publisher and consumer framework.

304.2k](/packages/nimbly-syndicate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
