laikait / lphp
Module-first, hook/filter driven backend PHP framework.
Requires
- php: ^8.2
- ext-intl: *
- ext-json: *
- ext-mbstring: *
- ext-pdo: *
- psr/container: ^2.0
- twig/twig: ^3.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP framework for large backend applications: ERP, billing, hosting control panels, SaaS backends, admin platforms and API-heavy systems.
Your application is built from modules. A module is one folder under
modules/ that brings its own pages, API endpoints, console commands, database
tables and background jobs. Delete the folder and all of it is gone, because
nothing outside the folder refers to it.
Status: 2.1.2, the first release. Everything in the specification is built except the demo application (Phase 29), which is postponed. Every public API is Experimental; nothing is marked Stable yet. See API stability, What is not built and Implementation status.
What you need
- PHP 8.2 or newer, with the
intl,json,mbstringandpdoextensions. On XAMPP,intlis switched off: openphp\php.iniand remove the;in front ofextension=intl. - Composer 2, PHP's package manager.
- A PDO driver for your database, for example
pdo_mysql.pdo_sqliteis enough to try everything, including the tests. fileinfo, only if your application accepts file uploads.
To see which extensions you have, run php -m.
Install and run it
composer install # download the framework's dependencies composer serve # start a development server
Open http://127.0.0.1:8080/. You should see Your application is running.
On XAMPP you can skip composer serve: the application also answers at
http://localhost/framework/ without any setup.
Two more commands you will use all the time:
php laika # list every console command composer check # coding standard + static analysis + tests
What a fresh install contains
| Folder | What is in it |
|---|---|
modules/Shared/ |
The one module that ships. It owns the home page, /. |
modules/Plugins/, modules/Gateways/ |
Not there yet. You create them for your own modules: a plugin is a feature, a gateway connects to an outside service such as a payment provider. |
templates/ |
The site's pages: a layout, the home page and the error pages, as Twig files. |
config/ |
Your settings, as PHP files. Empty until you need one. |
engine/ |
The framework itself. You do not edit it. |
public/ |
The only folder the web server may serve: index.php and public assets. |
system/ |
Files the framework writes: logs, caches, sessions. |
So a fresh install answers two pages:
curl -i http://127.0.0.1:8080/ # the home page curl -i http://127.0.0.1:8080/no/such/page # the "not found" page curl -i -H 'Accept: application/json' \ http://127.0.0.1:8080/no/such/page # the same error, as JSON
To replace the home page, declare a / route in a module of your own. See
The default pages.
There is no example application in modules/. The documentation's examples use a
plugin called Example, which lives in tests/Fixtures/Showcase/ as a test
fixture: worth reading, but not part of an installation.
Where to go next
| You want to | Read |
|---|---|
| learn the framework | Getting started: build a small module, step by step, in about half an hour |
| build something | the guides: pages and forms, JSON APIs, storing data, background work, users and permissions, extending modules, testing |
| look up how one part works | the reference, one page per part |
| put it on a server | Running in production, Deployment and security, Troubleshooting |
| change the framework itself | Contributing |
A fresh install has no user accounts and no login page. You add your own; see Users and permissions.
How it is built
What happens to one request:
public/index.php the web server hands every request here
-> engine/bootstrap.php sets up the framework
-> Application::boot() finds the modules and lets each one register
-> HttpKernel::handle() turns the Request into a Response
-> Router finds which handler the URL belongs to
-> Dispatcher builds the handler and calls it
-> Hooks / Filters let other modules react or change values
Web pages and JSON APIs go through the same kernel. Console commands
(php laika ...) use the same setup, without the HTTP part.
It is deliberately not MVC, and not a copy of Laravel, Symfony or CodeIgniter. Modules are the main way to split an application; hooks and filters are how modules extend each other; and database access is written out rather than hidden behind an ORM.
License
MIT. See LICENSE.