Download the PHP package libertyphp/libertyphp without Composer
On this page you can find all versions of the php package libertyphp/libertyphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download libertyphp/libertyphp
More information about libertyphp/libertyphp
Files in libertyphp/libertyphp
Package libertyphp
Short Description The Liberty PHP framework. Fast and extensible micro framework for PHP.
License MIT
Homepage https://github.com/vblila/libertyphp
Informations about the package libertyphp
Liberty PHP
Fast and extensible micro framework for PHP. Liberty PHP helps you build RESTful web applications quickly and easily.
Philosophy of the project =========================
- Large frameworks have a lot of extra functionality that reduce code performance. Preferably to use an extensible framework, where the developer decides which part of the framework he wants to write himself or find a suitable extension.
- The framework should contain only the functionality that will be used by 99% in project. All optional functionality should be on extensions.
- There shouldn't be any "magic" in frameworks (like in Laravel). Only clear method calling and object access.
- Clear code is better than short code.
Installation and quick start
Install
Install Liberty PHP with composer
Make directories like this:
Class autoload
Append to autoload rule:
Error handler
Create file with content:
DI container
Set up a container for HTTP request. Create file with content:
Core file
Create file with content:
Layout view
Create view file with content:
Index page
Create view file with content:
Controller with many actions is bad solution (violates the Single Responsibility Principle). Each action must be in separated class. Create action controller file with content:
Router
Create file with content:
Public script
Create public file with content:
Nginx configuration
Use this template for Nginx configuration:
Summary
At the end there will be such a directory and file structure:
Now you can open the project in the browser.
Data Access Layer
To work with relational databases, we recommend using Liberty PHP Datamapper
Logging
There is only one logger implementation available in the LibertyPHP - SimpleLogger (PSR LoggerInterface implementation). Append this code to :
Logger usage example:
Routing
Route rules example to demonstrate the possibilities of routing:
Use of middlewares (PSR MiddlewareInterface implementation) in routes is available:
Views
The easiest way to render view content is to use the class . Example:
Base view
Instance of class allows adding stylesheets and scripts files at render time.
Code example in controller:
Code example in view:
Layout view
Instance of class allows adding title, keywords and description. Rendering of layout view requires content view. First, the content view will be rendered, then the layout will be.
Code example in controller:
Code example in layout view:
Pagination
The Liberty PHP allows to quickly create a classic pagination. Example code in controller:
Example code in view:
Utils
Randomizer
The Liberty PHP allows generating cryptographically secure UUID v4. Example:
And cryptographically secure hex. Example:
List by key
It often happens that from a list of arrays or from an list of objects you need to create an associative array, in which the key will be the value of the array column or the property of the object. Simple way to do it:
Copyright
Copyright (c) 2018-2022 Vladimir Lila. See LICENSE for details.
All versions of libertyphp with dependencies
psr/log Version ^1.1.4
psr/container Version ^2.0.2
psr/http-message Version ^1.0.1
psr/http-server-middleware Version ^1.0.1
guzzlehttp/psr7 Version ^2.4.1