1. Go to this page and download the library: Download migears/utils 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/ */
migears / utils example snippets
use MiGears\Utils\URL;
// A string carrying its own scheme parses as-is
$url = URL::parse('https://example.com/path?page=1');
$url->scheme(); // 'https'
$url->host(); // 'example.com'
$url->path(); // '/path'
$url->query(); // ['page' => '1']
$url->queryParam('page'); // '1'
$url->isHttps(); // true
// http() and https() force their scheme
URL::https('example.com/path'); // https://example.com/path
URL::http('https://example.com'); // http://example.com/
// Without a scheme and without a factory, the string is rejected
URL::parse('example.com/path'); // throws InvalidArgumentException
new URL(scheme: '1a', host: 'example.com'); // throws — not a valid scheme
new URL(scheme: 'https', host: 'exa mple.com'); // throws — a host cannot carry a space
new URL(scheme: 'https', host: 'a.com', port: 70000); // throws — not a destination port
(new URL(scheme: 'https', host: 'a.com'))->withPath('/a b/c')->toString();
// 'https://a.com/a%20b/c'
use MiGears\Utils\FlowPaginator;
$paginator = FlowPaginator::first(20, 'id');
// After fetching data...
$next = $paginator->nextPage($items, $hasMore);
$next->nextCursor(); // cursor for the next page
$next->hasMore(); // whether there are more pages
$next->toArray(); // for JSON response