PHP code example of irmmr / handle

1. Go to this page and download the library: Download irmmr/handle 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/ */

    

irmmr / handle example snippets


use Irmmr\Handle\App\Err;

// listen database errors
Err::listen(ERROR_TYPE, function ($error) {
    if (is_null($error)) return;
    echo $error->getMessage();
});

use Irmmr\Handle\Data as D;

// Remove from string . return: Homan!
echo D::remove()->str('Hello man!', 'e', 'l', ' ');

// Remove from string. return: Homan!
echo D::remove()->strFormat('Hello man!', '/[el ]/');

use Irmmr\Handle\Package as Pack;
use Irmmr\Handle\Data;

// example import with  'my-dir')
    ->base(__DIR__)->do();

// block some files
Pack::import('one-dir')
    ->base(__DIR__, '

use Irmmr\Handle\Method;

// get method type
echo Method::type();

// check method type
if (Method::isType(Method::GET)) {
    echo 'It\'s GET.';
}

// check and get a sample GET method
if (Method::get()->has('page')) {
    $page = Method::get()->get('page');
} else {
    $page = 1;
}

// or
$page = Method::get()->get('page') ?? 1;

// or with default value
$page = Method::get()->get('page', 1);

use Irmmr\Handle\Filer as F;

// get file size
echo F::file()->size('path.txt');

// make dir
F::dir()->make('my-dir');

use Irmmr\Handle\Filer;

// extract all php and html files example (return array)
$files = Filer::extract('.')    // path
    ->base(__DIR__)             // main directory
    ->loop()                    // enable loop dirs
    ->extensions('php', 'html') // set valid extensions
    ->get();

// extract some folders of project
$files = Filer::extract('*.json', 'src', 'other-dir')
    ->base(__DIR__, 'vendor')
    ->loop()
    ->extensions('json')
    ->get();