14.7. Using Google CodeSearch

Google CodeSearch is a search engine that indexes many open-source software projects on the internet. You can use Zend_Gdata_CodeSearch to query this index, to find code that matches certain text patterns.

See http://code.google.com/apis/codesearch/overview.html for more information about the Google CodeSearch API.

Use the setQuery() method to specify search expressions. The expressions are regular expressions. You can list multiple expressions in the string you pass to setQuery(), separated by spaces.

<?php
$gdataCode = new Zend_Gdata_CodeSearch();
$gdataCode->setQuery('malloc');
$gdataCode->setMaxResults(20);
$feed = $gdataCode->getCodeSearchFeed();
?>

See the documentation for Zend_Feed for more information on how to use this object.

The startIndex and maxResults parameters are also supported. No other request parameters are supported by Google CodeSearch.

The feeds returned by Google CodeSearch are read-only. There are no operations that require an authenticated Http client.