Documentation
NiangPro Documentation
NiangPro is a PHP micro-framework: router, dependency injection, minimal ORM, validation, authentication, testing — with no runtime implementation dependencies (only the PSR-11/PSR-3/PSR-7/PSR-15 interfaces, for interoperability). This documentation is itself an ordinary NiangPro project: nothing here is an external rendering engine.
Getting started
Install NiangPro, create a project and take a first tour of the generated structure.
Core concepts
The request lifecycle, the Container, reflection-based injection, Service Providers.
Routing
Parameters, constraints, groups, domains, resource routes, HEAD/OPTIONS, route caching.
This documentation is a work in progress: three sections are written and checked against the source code (see the contents on the left). The other sections already appear there, marked “soon”, to show the complete plan.
Why NiangPro?
The framework's composer.json sums it up this way: “an ultra-simple PHP micro-framework,
simpler than Laravel: router, DI, minimal ORM, auth, tests, with no runtime implementation
dependencies”. Every new project is a full copy of the framework (not a Composer package required
as a dependency): src/ and app/ travel together, and there is nothing to
publish on Packagist for your code to run.
Getting started
composer create-project niangpro/niangpro my-app
cd my-app
./bin/niang serve
See Getting started for the details of each step.
The np shortcut
To type np serve instead of ./bin/niang serve, install the global shortcut
once. It works on macOS, Linux and Windows:
# macOS / Linux
./bin/niang np:install
# Windows (cmd or PowerShell)
php bin/niang np:install
The command drops a small np script (on Windows, np.cmd) into a folder on
your PATH. That script walks up from the current folder until it finds
bin/niang, so np works in every NiangPro project, even from
a subfolder, with nothing to configure per project.
np serve
np make:controller PostController
np migrate
If no folder on your PATH is writable, np is installed in
~/.local/bin (Windows: %LOCALAPPDATA%\NiangPro\bin) and the command
prints the exact line to run once to add that folder to your PATH. Then open a new
terminal.