jclyons52/php-query
Composer 安装命令:
composer require jclyons52/php-query
包简介
jQuery / javascript api for html document manipulation in php
关键字:
README 文档
README
Nobody really wants to do imperative dom manipulation on the back end, but sometimes you have to. Given that you've probably done a lot of dom manipulation in javascript, maybe it would be nice to use the same api on the back end. Use cases for this project include:
- DOM Crawlers
- Integration testing
- Link previews
Install
Via Composer
composer require jclyons52/php-query
Usage
$html = <div class="row"> <div class="col-sm-3" id="div-1"> First Div </div> <div class="col-sm-3" id="div-2"> Second Div </div> <div class="col-sm-3 third" id="div-3" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'> Third Div </div> </div>'; $dom = new Jclyons52\PHPQuery\Document($html); $elements = $dom->querySelector('.col-sm-3'); $element->attr('styles', 'display: block;'); echo $element->attr('styles'); // 'display: block' echo $element->text(); // 'First Div' echo $element->hasClass('col-sm-3); // true $element->css(); // ["color" => "blue", "display" => "none"]; $div3 = $dom->querySelectorAll('.col-sm-3')[2]; $div3->data(); // ["last-value" => 43, "hidden" => true, "options" => '{"name":"John"}'] echo $element->toString(); // '<div class="col-sm-3" id="div-1"> First Div </div>'
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email jclyons52@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 702
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-05