PHPackages                             grepper/grepper-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. grepper/grepper-php

ActiveLibrary[API Development](/categories/api)

grepper/grepper-php
===================

Grepper PHP Library

1.0.3(3y ago)8143MITPHPPHP &gt;=5.6.0

Since Mar 25Pushed 3y ago2 watchersCompare

[ Source](https://github.com/CodeGrepper/grepper-php)[ Packagist](https://packagist.org/packages/grepper/grepper-php)[ Docs](https://www.grepper.com)[ RSS](/packages/grepper-grepper-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Grepper PHP client
==================

[](#grepper-php-client)

The Grepper PHP library provides convenient access to the Grepper API from applications written in the PHP language.

Requirements
------------

[](#requirements)

PHP 5.6.0 and later.

Composer
--------

[](#composer)

You can install the php client via [Composer](http://getcomposer.org/). Run the following command:

```
composer require grepper/grepper-php
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once 'vendor/autoload.php';
```

Manual Installation
-------------------

[](#manual-installation)

If you do not wish to use Composer, you can download the [latest release](https://github.com/grepper/grepper-php/releases). Then, to use the php client, include the `init.php` file.

```
require_once '/path/to/grepper-php/init.php';
```

Dependencies
------------

[](#dependencies)

The bindings require the following extensions in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Getting Started
---------------

[](#getting-started)

Simple usage looks like:

```
$grepper = new \Grepper\GrepperClient('your_api_key_here');
$answers = $grepper->answers->search([
    'query' => 'javascript loop array backwords'
]);
print_r($answers);
```

Documentation
-------------

[](#documentation)

See the [PHP API docs](https://grepper.com/docs/api/?lang=php#intro).

Custom Request Timeouts
-----------------------

[](#custom-request-timeouts)

To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.

```
// set up your tweaked Curl client
$curl = new \Grepper\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Grepper\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Grepper\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT

echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5

// tell Grepper to use the tweaked client
\Grepper\ApiRequestor::setHttpClient($curl);

// use the Grepper API client as you normally would
```

Custom cURL Options (e.g. proxies)
----------------------------------

[](#custom-curl-options-eg-proxies)

Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array to the CurlClient constructor, using the same syntax as `curl_stopt_array()`. This will set the default cURL options for each HTTP request made by the SDK, though many more common options (e.g. timeouts; see above on how to set those) will be overridden by the client even if set here.

```
// set up your tweaked Curl client
$curl = new \Grepper\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
// tell Grepper to use the tweaked client
\Grepper\ApiRequestor::setHttpClient($curl);
```

Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.

### Configuring a Logger

[](#configuring-a-logger)

The library does minimal logging, but it can be configured with a \[`PSR-3` compatible logger\]\[psr3\] so that messages end up there instead of `error_log`:

```
\Grepper\Grepper::setLogger($logger);
```

### Accessing response data

[](#accessing-response-data)

You can access the data from the last API response on any object via `getLastResponse()`.

```
$answers = $grepper->answers->search([
    'query' => 'js loop',
]);
echo $answers->getLastResponse()->headers['Request-Id'];
```

### Configuring CA Bundles

[](#configuring-ca-bundles)

By default, the library will use its own internal bundle of known CA certificates, but it's possible to configure your own:

```
\Grepper\Grepper::setCABundlePath("path/to/ca/bundle");
```

### Configuring Automatic Retries

[](#configuring-automatic-retries)

The library can be configured to automatically retry requests that fail due to an intermittent network problem:

```
\Grepper\Grepper::setMaxNetworkRetries(2);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1150d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0959b1d52d2ac211742ab0280b502b88bb1426b6c90c7154e2e7c4225c3225bd?d=identicon)[Grepper](/maintainers/Grepper)

---

Tags

apigreppergrepper php clientgrepper api

### Embed Badge

![Health badge](/badges/grepper-grepper-php/health.svg)

```
[![Health](https://phpackages.com/badges/grepper-grepper-php/health.svg)](https://phpackages.com/packages/grepper-grepper-php)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
