inteve / utils
用于Web开发的工具类
v0.3.4
2023-06-27 06:46 UTC
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
用于Web开发的工具类
安装
composer require inteve/utils
Inteve\Utils 需要 PHP 5.6.0 或更高版本。
用法
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
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
许可协议: 新BSD许可协议
作者: Jan Pecha, https://www.janpecha.cz/