[jQuery] PHP port of jQuery
Hi,
I would like to introduce you phpQuery - jQuery port to PHP.
http://code.google.com/p/phpquery/
There was one topic mentioning about it, but it is one year old and i
decided to start a new one.
phpQuery implements following portions of jQuery API:
1. Selectors
2. Attributes
3. Traversing
4. Manipulation
Today library seems to be quite stable, there is couple of test cases,
but massive public tests would be very appreciated.
License is MIT, like jQuery.
Latest release download (as for today):
http://phpquery.googlecode.com/files/phpQuery-0.9.1-beta2.zip
SVN checkout for latest releases:
svn checkout http://phpquery.googlecode.com/svn/trunk/ phpQuery
Here's some showoff snippet:
<?php
// just one file to include
require('phpQuery/phpQuery.php');
// intialize new DOM from markup
phpQuery::newDocument('<div>mydiv<ul><li>1</li><li>2</li><li>3</li></
ul></div>')
->find('ul > li')
->addClass('my-new-class')
->filter(':last')
->addClass('last-li');
// query all unordered lists in last used DOM
pq('ul')->insertAfter('div');
// iterate all LIs from last used DOM
foreach(pq('li') as $li) {
// iteration returns plain DOM nodes, not phpQuery objects
pq($li)->addClass('my-second-new-class');
}
// same as pq('anything')->htmlOuter() but on document root (returns
doctype etc)
print phpQuery::getDocument();
?>
Hope you will like it :)