This project has been moved to another repository: https://github.com/alma3lol/APLib
A PHP library to create your website smooth, easy & secure.
- Download APLib:
cd [DOCUMENT ROOT]
git clone https://github.com/almapro/APLib.git
- Download APLib externals:
git clone https://github.com/almapro/APLib-ext.git
- Put everything in place:
- Move all sub folders of APLib-ext folder to
DOCUMENT ROOT
- Move all sub folders of APLib-ext folder to
Using APLib can be complex, but let's start step-by-step:
-
Include APLib in your project:
require_once('PATH/TO/APLib/core.php');
-
Initiate the library:
\APLib\Core::init();
-
Optionally configure settings using config class:
\APLib\Config::set('SETTING NAME', 'SETTING VALUE');
For example:
\APLib\Config::set('title', "My page's title");
This will set the page's title (
<title>My page's title</title>
).
-
-
Add your body:
\APLib\Response\Body::add("<h3>Hello code</h3>");
-
Run the library to deliver your page:
\APLib\Core::run();
APLib's structure is very easy to understand. You can find anything in a class path related to the usage path.
-
If you need to print a JavaScript code in the body of the page, then go as follows:
Response -> Body -> JavaScript -> Add
In code:
\APLib\Response\Body\JavaScript::add("// CODE HERE");
NOTE: The JavaScript code above is a code without
<script />
tags. -
To check if the request was a POST request, then do as follows:
Request -> HTTP -> POST
In code:
if(\APLib\Request\HTTP::post()) { // Do some post handling here }
-
To check if the request was a JSON payload:
Request -> HTTP -> JSON
In code:
if(\APLib\Request\HTTP::json()) { // Do some JSON handling here }
- Read the JSON payload:
In code:
Request -> HTTP -> Data
$payload = \APLib\Request\HTTP::data();
- Read the JSON payload:
Now with this explanation of how APLib is structured, you can find pretty much everything.
You can see the wiki for a better understanding of what APLib is capable of.
APLib now has a repository for examples: https://github.com/almapro/APLib-Examples/.