inteve / utils
Utility classes for web development
Fund package maintenance!
Other
Installs: 6 272
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
- nette/utils: ^2.4.4 || ^3.0 || ^4.0
Requires (Dev)
- nette/di: ^2.4 || ^3.0
- nette/tester: ^2.0
README
Utility classes for web development
Installation
Download a latest package or use Composer:
composer require inteve/utils
Inteve\Utils requires PHP 5.6.0 or later.
Usage
DateTimeFactory
$dateTimeFactory = new Inteve\Utils\DateTimeFactory; $now = $dateTimeFactory->create();
Imagick
use Inteve\Utils\ImagickHelper; $imagick = ImagickHelper::openImage('file.jpg'); ImagickHelper::resize($imagick, $width, $height, $flags); // same parameters as for Image::resize() ImagickHelper::saveImage($imagick, 'thumb.jpg'); // and much more!
PaginatorHelper
$paginator = new Nette\Utils\Paginator; $steps = Inteve\Utils\PaginatorHelper::calculateSteps($paginator);
XmlDocument
$xml = new Inteve\Utils\XmlDocument([ 'standalone' => 'yes', ]); $root = $xml->create('urlset'); $item = $root->create('url'); $item->create('loc')->setText('http://example.com/'); echo $xml->toString();
Prints:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <urlset> <url> <loc>http://example.com/</loc> </url> </urlset>
XmlQuery
Wrapper of SimpleXml.
$query = Inteve\Utils\XmlQuery::fromString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <urlset> <url> <loc>http://example.com/</loc> </url> <url> <loc>http://example.com/path</loc> </url> </urlset>'); $urls = []; foreach ($query->children('url') as $url) { $urls[] = $url->child('loc')->text(); } var_dump($urls);
Prints:
http://example.com/
http://example.com/path
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/