Wallogit.com
2017 © Pedro PelĆ”ez
PHPLib for code optimization and clean.
Vourto is a PHP library that allows agility and usability on the code. The best solution currently., (*1)
You can download the library using Composer (recommended) or simply download it directly from GitHub repository., (*2)
Download the composer file (composer.json) from our repository to you local/public server or copy the below code, (*3)
{
"name": "vourto/vourto",
"description": "PHPLib for code optimization and clean.",
"type": "library",
"keywords": ["Vourto", "lib"],
"license": "MIT",
"authors": [
{
"name": "Mauro Alexandre",
"email": "profissionalweb04@gmail.com",
"role": "Development"
}
],
"require": {
"php": "^5.6.2 || ^7.0"
}
}
composer require vourto/vourto### Direct download Clone the repositorygit clone https://github.com/developerdevice/Vourto.gitor [download directly](https://github.com/developerdevice/Vourto/archive/master.zip) ## Integrating To use the library you must include autoload.php in your applicationrequire_once "Vourto/autoload.php";$app = Prop::exec(method [POST | GET], data [array], callback [function]);
See below the syntax for better learningrequire_once "Vourto/autoload.php"; $app = Prop::exec( $_GET, array("profile" => array( "id" => array( "callback" => "ID cannot be empty" ) )) ); echo $app->getStd(); $app->close(); //output (onfail) //ID cannot be empty //output (onsuccess) //true
NOTE: if isnāt defined the callback returns true case onsuccess event be acioned. the first example verifies if `$_GET['id']` exists and returns a notice error.$app = Prop::exec( $_GET, array("profile" => array( "id" => array( "callback" => "ID cannot be empty" ) )), function(){ //code here }); //output (onfail) //ID cannot be empty //output (onsuccess) //[generated the code]
You can use a callback in the event onsuccessrequire_once "Vourto/autoload.php"; $app = Prop::exec( $_GET, array("profile" => array( "id" => array( "minlegth" => array("value" => 4, "callback" => "ID must be at least 4 characters"), "maxlegth" => array("value" => 11, "callback" => "ID must be a maximum of 11 characters"), "callback" => "ID cannot be empty" ) )), function(){ header("location: page.php?id=${_GET["id"]}"); }); echo $app->getStd(); $app->close();
The next examples verifies if id exists and if it's length is < 4 or > 11if(isset($_GET["id"] === false)){ echo "ID cannot be empty"; }elseif(strlen($_GET["id"]) < 4){ echo "ID must be at least 4 characteres"; }elseif(strlen($_GET["id"]) > 11){ echo "ID must be a maximum of 11 characters"; }else{ header("location: page.php?id=${_GET["id"]}"); }
The code above is equivalent to the below code
Now try verifying 2 elements using a lot of if statement's and compare it to using Vourto LIB., (*4)
There are yet another functions: - type [numeric, doubleā¦] - pattern [regex], (*5)
To see more examples: search the path named /bin/ and open the examples files., (*6)
Having trouble with lib ? Contact me and I'll help you sort it out., (*7)