PHPackages                             scafera/kernel - 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. scafera/kernel

ActiveLibrary[Framework](/categories/framework)

scafera/kernel
==============

Kernel package for the Scafera framework

v1.0.7(1mo ago)02010MITPHPPHP &gt;=8.4

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/scafera/kernel)[ Packagist](https://packagist.org/packages/scafera/kernel)[ Docs](https://github.com/scafera/kernel)[ RSS](/packages/scafera-kernel/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (5)Versions (9)Used By (10)

scafera/kernel
==============

[](#scaferakernel)

Scafera Kernel is the execution core of the Scafera framework. It provides a minimal, controlled runtime environment and defines the boundaries within which applications operate.

> **Provides:** The boot core of Scafera — discovers bundles, loads an architecture package, enforces structural boundaries, and hands off to Symfony. User projects never define a Kernel.
>
> **Depends on:** A host project with a standard layout (`public/`, `var/`, `config/`), a Composer-installed architecture package implementing `ArchitecturePackageInterface`, Symfony 8 + FrameworkBundle, and an `APP_SECRET` provided via `config/` overrides or OS env.
>
> **Extension points:**
>
> - Contracts in `Scafera\Kernel\Contract\` — `ArchitecturePackageInterface` (primary), `ValidatorInterface`, `AdvisorInterface`, `GeneratorInterface`, `PathProviderInterface`, `ViewInterface`
> - Attributes — `#[Route]` (HTTP), `#[AsCommand]` (CLI), `#[Config]` (env/parameter injection)
> - DI tags — `scafera.validator`, `scafera.advisor`, `scafera.path_provider` (auto-collected)
>
> **Not responsible for:** Routing/commands/services without an architecture package · folder conventions (owned by architecture packages) · presentation (`scafera/frontend`) · persistence (`scafera/database`) · logging (`scafera/log`) · HTTP header/CORS customization · `.env` files · `config/packages/` scanning · userland event dispatch.

Headless by design
------------------

[](#headless-by-design)

The kernel is intentionally non-functional without an architecture package. Without one:

- No user services are discovered or registered
- No routes are loaded (HTTP returns 404)
- Only built-in commands work (`about`, `validate`, `cache:clear`)

Install an architecture package (e.g. `scafera/layered`) to define structure, behavior, and rules.

Design principles
-----------------

[](#design-principles)

- **Explicit execution** — no hidden or implicit behavior in userland
- **Separation of concerns** — runtime and architecture are independent
- **Extensibility through contracts** — behavior is defined by implementing packages

How it works
------------

[](#how-it-works)

### Dynamic bundle discovery

[](#dynamic-bundle-discovery)

Bundles are discovered automatically from Composer's `installed.json`. Any installed package declaring `"type": "symfony-bundle"` is registered at boot — no `config/bundles.php` needed.

- Install a capability package and its bundle is available
- Remove a package and its bundle disappears
- `composer install --no-dev` naturally excludes dev bundles

### Configuration

[](#configuration)

User configuration goes in a single optional file:

```
config/config.yaml

```

This file can override any bundle configuration and set environment variables:

```
env:
  APP_DEBUG: '0'

framework:
  session:
    cookie_secure: true
```

Secrets like `APP_SECRET` belong in `config/config.local.yaml` (git-ignored). The scaffold plugin generates this file with a random secret during `composer create-project`.

There is no `config/packages/` directory — the kernel does not scan for it.

### Environment bootstrap

[](#environment-bootstrap)

The `Bootstrap` class handles environment setup before the Symfony runtime takes over:

1. Sets `APP_ENV` and `APP_DEBUG` defaults (`dev` / `1`)
2. Reads the `env:` section from `config/config.yaml` if present
3. Real OS environment variables always take precedence
4. Validates that `APP_SECRET` is set

Contracts
---------

[](#contracts)

The kernel defines contracts that architecture and capability packages implement:

ContractPurpose`ArchitecturePackageInterface`Defines an architecture package`ValidatorInterface`Hard validation rule (affects exit code)`AdvisorInterface`Soft advisory check (never affects exit code)`GeneratorInterface`Code generator for `scafera make:*` commands`PathProviderInterface`Registers paths shown by `info:paths``ViewInterface`Template rendering (implemented by `scafera/frontend`)HTTP types
----------

[](#http-types)

Controllers use these types instead of Symfony's HTTP classes directly. The `ControllerBoundaryPass` enforces this at compile time.

TypePurpose`Scafera\Kernel\Http\Request`Wraps the incoming HTTP request`Scafera\Kernel\Http\Response`Plain HTTP response`Scafera\Kernel\Http\JsonResponse`JSON HTTP response`Scafera\Kernel\Http\RedirectResponse`Redirect HTTP response`Scafera\Kernel\Http\Route`Attribute for defining routes`Scafera\Kernel\Http\ParameterBag`Query and request parameters (typed getters)`Scafera\Kernel\Http\HeaderBag`Request headers (case-insensitive)All types live in `Scafera\Kernel\Http\`.

### Console

[](#console)

TypePurpose`Scafera\Kernel\Console\Command`Base command class with `handle()` method`Scafera\Kernel\Console\Input`Command input wrapper`Scafera\Kernel\Console\Output`Command output wrapper with `success()`, `error()`, `warning()``Scafera\Kernel\Console\Attribute\AsCommand``#[AsCommand]` attribute### Testing

[](#testing)

TypePurpose`Scafera\Kernel\Test\WebTestCase`HTTP test base with `get()`, `post()`, etc.`Scafera\Kernel\Test\TestResponse`Fluent assertions: `assertOk()`, `assertJsonPath()`, etc.`Scafera\Kernel\Test\CommandTestCase`Console test base`Scafera\Kernel\Test\CommandResult`Command output assertions### Example controller

[](#example-controller)

```
use Scafera\Kernel\Http\Request;
use Scafera\Kernel\Http\Response;
use Scafera\Kernel\Http\Route;

#[Route('/orders/{id}', methods: 'GET', requirements: ['id' => '\d+'])]
final class ShowOrder
{
    public function __invoke(Request $request): Response
    {
        $id = $request->routeParam('id');
        // ...
        return new Response($content);
    }
}
```

### Request

[](#request)

Properties:

- `$request->query` — `ParameterBag` of query string parameters
- `$request->request` — `ParameterBag` of POST body parameters
- `$request->headers` — `HeaderBag` of request headers

Methods:

- `getMethod(): string` — HTTP method (GET, POST, etc.)
- `isMethod(string $method): bool`
- `getPath(): string` — URL path without query string
- `getUri(): string` — full URI
- `getContent(): string` — raw request body
- `json(): array` — parsed JSON body
- `routeParam(string $key, mixed $default = null): mixed` — single route parameter
- `routeParams(): array` — all route parameters

### Response types

[](#response-types)

```
new Response(string $content = '', int $status = 200, array $headers = [])
new JsonResponse(mixed $data = null, int $status = 200, array $headers = [])
new RedirectResponse(string $url, int $status = 302, array $headers = [])
```

### Route attribute

[](#route-attribute)

```
#[Route(
    path: '/path/{param}',
    methods: 'GET',              // string or array: ['GET', 'POST']
    name: 'custom_route_name',   // optional, auto-generated if omitted
    requirements: ['param' => '\d+'],
    defaults: ['param' => '1'],
)]
```

Class-level `#[Route]` sets a prefix for method-level routes. A class-level `#[Route]` with no method-level routes maps to `__invoke`.

### ParameterBag

[](#parameterbag)

- `get(string $key, mixed $default = null): mixed`
- `has(string $key): bool`
- `all(): array`
- `getInt(string $key, int $default = 0): int`
- `getString(string $key, string $default = ''): string`
- `getBoolean(string $key, bool $default = false): bool`

### HeaderBag

[](#headerbag)

- `get(string $key, ?string $default = null): ?string` — case-insensitive lookup
- `has(string $key): bool`
- `all(): array`

Built-in commands
-----------------

[](#built-in-commands)

```
vendor/bin/scafera validate           # Run all validators and advisors from installed Scafera packages
vendor/bin/scafera about              # Show framework and environment information
```

Scafera Packages
----------------

[](#scafera-packages)

### Architecture packages

[](#architecture-packages)

Define folder structure, service discovery, and convention enforcement.

PackageDescription`scafera/layered`Layered architecture conventions### Capability packages

[](#capability-packages)

Add optional functionality. Install only what you need.

PackageDescription`scafera/auth`Authentication and access control`scafera/database`Database persistence (Doctrine)`scafera/file`File upload, validation, and storage`scafera/form`Form handling and DTO validation`scafera/frontend`Template rendering (Twig)`scafera/log`Structured logging (PSR-3)`scafera/translate`Translation and locale management### Tooling

[](#tooling)

PackageDescription`scafera/scaffold`Composer plugin that scaffolds project files### Project templates

[](#project-templates)

PackageDescription`scafera/layered-web`Layered web application templateRequirements
------------

[](#requirements)

- PHP &gt;= 8.4
- Symfony 8

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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 ~1 days

Total

8

Last Release

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9233f415f42755f68dc3006e2853b76c34de54b04c9535202b70aa147790e6a?d=identicon)[samaphp](/maintainers/samaphp)

---

Top Contributors

[![samaphp](https://avatars.githubusercontent.com/u/531627?v=4)](https://github.com/samaphp "samaphp (62 commits)")

---

Tags

phpframeworkkernelscafera

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scafera-kernel/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M506](/packages/shopware-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M195](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[oro/platform

Business Application Platform (BAP)

641140.7k103](/packages/oro-platform)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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