PHPackages                             nixphp/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. [API Development](/categories/api)
4. /
5. nixphp/framework

ActiveLibrary[API Development](/categories/api)

nixphp/framework
================

NixPHP - the ultra-light, functional PHP framework for fast microservices and APIs.

v0.1.4(2mo ago)031412MITPHPPHP &gt;=8.3CI passing

Since Nov 27Pushed 2mo ago1 watchersCompare

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

READMEChangelog (4)Dependencies (8)Versions (11)Used By (12)

[![Logo](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)

[![NixPHP Build & Test](https://github.com/nixphp/framework/actions/workflows/php.yml/badge.svg)](https://github.com/nixphp/framework/actions/workflows/php.yml)

---

NixPHP
======

[](#nixphp)

> **"As simple as possible, as flexible as necessary."**

**NixPHP** is a modern, lightweight PHP microframework designed for real-world projects:
fast, minimal, extendable, and now fully embracing modern PHP standards like PSR-3, PSR-4, PSR-7, PSR-11, and PSR-18.

It builds on native PHP features and lets you stay in control:
**Use only what you need, and extend freely when you want.**

> 🧩 NixPHP provides a minimal core with a clean plugin architecture.
> Everything beyond routing and dispatching, such as sessions, views, forms, or database, is handled by optional plugins.
> You get full control over what your app includes, and nothing more.

---

✨ Philosophy
------------

[](#-philosophy)

- **Minimalist Core**: Only essential components by default.
- **PSR-First**: Native support for key PHP standards (PSR-3, PSR-4, PSR-7, PSR-11, PSR-18).
- **Extendable**: Easily plug in external libraries — Blade, Twig, Eloquent, Middleware, etc.
- **Transparent by Design**: No hidden magic, no complicated abstractions.
- **Native PHP Power**: PDO database, clean routing, lightweight templating.
- **Secure and Clear Structure**: Safe public directory (`public/`) separated from your app code.

---

Core Features
-------------

[](#core-features)

- **Plugin System**: Add reusable features via Composer
- **Lightweight Routing**: Define routes with `[Controller::class, 'method']`
- **Smart Dispatcher**: Automatic parameter and controller resolution
- **Dependency Container (PSR-11)**: Service registry with built-in autowiring
- **PSR-3 Logging** (lightweight logger ready to use)
- **PSR-4 Autoloading** (Composer)
- **PSR-7 Request/Response Handling**
- **PSR-18 HTTP Client** (via `nixphp/client`)
- **Minimalist View System**: Block-based templating (via `nixphp/view`)
- **PDO Database Connection** (via `nixphp/database`)
- **Session Handling** (via `nixphp/session`)
- **Form Memory Helpers** (via `nixphp/form`)
- **JSON Response Helper** (for easy API responses)
- **Composer-Ready**: Easy installation and dependency management

---

PSR Compliance Overview
-----------------------

[](#psr-compliance-overview)

PSRDescriptionStatusPSR-3Logger Interface✅ IntegratedPSR-4Autoloading Standard✅ Native via ComposerPSR-7HTTP Message Interface✅ IntegratedPSR-11Container Interface✅ IntegratedPSR-18HTTP Client Interface✅ Integrated---

❓ Why not just use Laravel or Symfony?
--------------------------------------

[](#-why-not-just-use-laravel-or-symfony)

Frameworks like Laravel and Symfony are fantastic, but they often come with a heavy stack of features, conventions, and dependencies you may not always need.

**NixPHP** offers a different approach:

- **No hidden complexity**: You see exactly what happens.
- **No forced patterns**: Use only what you need, when you need it.
- **No unnecessary overhead**: Keep performance and flexibility under your control.
- **Real extendability**: Bring your favorite libraries if needed — but stay light if you don't.

If you want full control without fighting against a "big framework" structure,
**NixPHP** might be the perfect starting point for you.

---

📢 Installation
==============

[](#-installation)

Install via Composer
--------------------

[](#install-via-composer)

```
composer require nixphp/framework
```

This installs the **NixPHP core**, a minimal routing and dispatch layer.
For additional features like views, forms, or sessions, just install the corresponding plugins.

---

Set up your project structure
-----------------------------

[](#set-up-your-project-structure)

NixPHP leaves the project organization completely up to you.
A typical structure could look like this:

```
/app
    /Controllers
    /Models
    /Services
    config.php
    routes.php
/public
    index.php
bootstrap.php
composer.json

```

- **Plural names** for app folders
- **`public/`** as webroot for higher security
- **`bootstrap.php`** for autoloading and bootstrapping services, registering events, and so on...

---

Creating your App
-----------------

[](#creating-your-app)

You typically...

- Create a `bootstrap.php` to initialize NixPHP
- Set up your `routes.php`
- Create a `public/index.php` as your web entry point (which includes bootstrap.php)

1. **Fill bootstrap.php**

```
// /bootstrap.php

define('BASE_PATH', __DIR__);

require __DIR__ . '/../vendor/autoload.php';

use function NixPHP\app;

app()->run(); // Start the application
```

2. **Create a route**

```
//File: app/routes.php

router()->add('GET', '/hello', [HelloController::class, 'index']);
```

3. **Create a controller**

```
//File: app/Controllers/HelloController.php

namespace App\Controllers;

class HelloController
{
    public function index()
    {
        return view('hello', ['name' => 'World']);
    }
}
```

4. **Create a view**

```
//File: app/views/hello.phtml

use function NixPHP\s; // Sanitize on output (provided through nixphp/view)

Hello, !
```

5. **Access your page**

Visit:

```
http://your-app.local/hello

```

You should see:

```
Hello, World!

```

---

🔧 Dependency Injection &amp; Autowiring
---------------------------------------

[](#-dependency-injection--autowiring)

NixPHP includes a **PSR-11 compliant container** with **automatic dependency resolution** built-in.
No configuration needed, it just works.

### Registering Services

[](#registering-services)

Register your core services (interfaces, databases, loggers) in the container:

```
use function NixPHP\app;

// Register interfaces (required for autowiring)
app()->container()->set(LoggerInterface::class, fn() => new FileLogger());
app()->container()->set(DatabaseInterface::class, fn() => new MySQLDatabase());
```

### Automatic Dependency Resolution

[](#automatic-dependency-resolution)

Controllers and services automatically receive their dependencies:

```
class UserService {
    public function __construct(
        private LoggerInterface $logger  // ✅ Automatically injected
    ) {}
}

class UserController {
    public function __construct(
        private UserService $service,    // ✅ Auto-built and injected
        private LoggerInterface $logger  // ✅ Retrieved from container
    ) {}
}

// No manual wiring needed - the dispatcher handles it automatically!
router()->add('GET', '/users', [UserController::class, 'index']);
```

### How It Works

[](#how-it-works)

NixPHP's autowiring follows these basic rules:

1. **Interfaces must be registered**: tell the container which implementation to use
2. **Concrete classes are auto-built**: no registration needed
3. **Dependencies are resolved recursively**: the entire dependency tree is handled

### Building Instances Manually

[](#building-instances-manually)

Sometimes you need to build instances directly (e.g., Commands):

```
// Build a fresh instance
$command = app()->container()->make(MigrateCommand::class);

// Build with custom parameters
$handler = app()->container()->make(RequestHandler::class, [
    'timeout' => 30,
    'retries' => 3
]);

// Build as a singleton (stored in the container for reuse)
$service = app()->container()->make(CacheService::class, singleton: true);
```

### Features

[](#features)

- **Zero configuration**: autowiring works out of the box
- **Concrete classes auto-resolve**: less boilerplate
- **Circular dependency detection**: prevents infinite loops
- **Nullable dependencies**: handled gracefully
- **Optional parameters**: with default values supported
- **Custom parameters**: pass explicit values when needed

### Best Practices

[](#best-practices)

What to RegisterWhyInterfaces (e.g., `LoggerInterface`)Required for autowiringDatabase connectionsSingleton configurationThird-party servicesComplex initializationConfiguration objectsShare across applicationWhat NOT to RegisterWhyControllersAuto-built by dispatcherSimple servicesAuto-resolved on demandValue objectsCreated as neededCommandsBuilt via `make()`---

🔌 Plugin Support
----------------

[](#-plugin-support)

NixPHP includes a clean plugin system that allows you to extend your app modularly — without configuration.

Just install a plugin via Composer (e.g. `composer require vendor/my-plugin`) and it is automatically detected if it uses the correct package type:

```
{
  "type": "nixphp-plugin"
}
```

A typical plugin might look like this:

```
my-plugin/
├── src/
│   ├── config.php
│   └── views/
│       └── errors/404.phtml
├── bootstrap.php
└── composer.json

```

- `config.php` is automatically merged.
- `views/` are added to the view search path.
- `bootstrap.php` runs automatically to register routes, events, etc.

### Plugin availability checks

[](#plugin-availability-checks)

Use `app()->hasPlugin('vendor/name')` to gate functionality on optional plugins. Version hints like `vendor/name:>=0.1.2` or `vendor/name: For plugin examples, see the [Plugin Documentation](https://nixphp.github.io/docs/plugins/)

---

License
=======

[](#license)

MIT License.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity46

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

Total

5

Last Release

85d ago

### Community

Maintainers

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

---

Top Contributors

[![FloKnapp](https://avatars.githubusercontent.com/u/3774820?v=4)](https://github.com/FloKnapp "FloKnapp (109 commits)")

---

Tags

apiframeworklightweightmicroframeworkmicroservicenixphpphpwebapp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

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

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)

PHPackages © 2026

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