1. Go to this page and download the library: Download iqomp/handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iqomp / handler example snippets
namespace App\Handler;
class User extends \Iqomp\Handler\Handler
{
// handling model
protected string $model = 'App\Model\User';
// formatter data for the object
// used for method `get`, `create`, and `getOne`
protected array $formatter = [
'name' => 'wallet',
'options' => []
];
// custom error code for form invalid or general error
protected array $errors_code = [
422 => 100004,
500 => 100003
];
// property name for pagination result per page
protected string $pager_rpp = 'per_page';
// property name for pagination result page number
protected string $pager_page = 'page';
// property name for pagination total result
protected string $pager_total = 'total';
// form name for each methods
protected array $forms = [
'create' => 'user/create',
'createMany' => 'user/createMany',
'set' => 'user/set'
];
// list of disallowed method to call
protected array $disalow_methods = [
'getConnection',
'getModel'
];
// custom function after
protected function after_create(array $fields, $result)
{
// the function that will be called right after
// creating the object
}
}
// ...
$user = new App\Handler\User;
// get formatted single object
$object = $user->getOne(['id' => 1]);
// create new user that should be validated
// and return the created one after formatted
$object = $user->create(['...']);
// get validation errors
$errors = $user->error();
// get users page 2
$objects = $user->get(['status' => 1], 12, 2);
// get paginations data
$pager = $user->pagination();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.