PHPackages                             iblank/laravel-gov-search - 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. iblank/laravel-gov-search

ActiveLibrary[API Development](/categories/api)

iblank/laravel-gov-search
=========================

This Laravel package integrates the USA Gov Search API. Use the config file to add your API token and affiliate.

v0.1(11y ago)038MITPHPPHP &gt;=5.3.0

Since Apr 14Pushed 11y ago1 watchersCompare

[ Source](https://github.com/iblank/laravel-gov-search)[ Packagist](https://packagist.org/packages/iblank/laravel-gov-search)[ RSS](/packages/iblank-laravel-gov-search/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

laravel-gov-search
==================

[](#laravel-gov-search)

Laravel PHP Facade/Wrapper for the USA.gov, DigitalGov Search API. You will need to create an account with DigialGov to create an affiliate id and access token key:

Installation
------------

[](#installation)

1. Add project to the require array in your `composer.json` file:

    ```
     "require": {
         "iblank/laravel-gov-search": "dev-master"
     }

    ```
2. Run `composer update` to pull down the latest version of the package.
3. Open `app/config/app.php`**\*** and add the service provider to your `providers` array:

    ```
     'providers' => array(
         'iblank\GovSearch\GovSearchServiceProvider'
     )

    ```

**\* NOTE:** if you are using environmental configurations, make sure to place the service provider in the `app.php` file respective to your environment.

Configuration
-------------

[](#configuration)

### For Laravel 5

[](#for-laravel-5)

Run `php artisan vendor:publish` and set your API key and affiliate id in the file:

```
/app/config/govsearch.php

```

### For Laravel 4

[](#for-laravel-4)

Run `php artisan config:publish iblank/laravel-gov-search` and set your API key and affiliate id in the file:

```
/app/config/packages/iblank/laravel-gov-search/config.php

```

### Default Options

[](#default-options)

Optionally change the default values for search requests using the `DEFAULTS` array in the config file:

```
'DEFAULTS' => array(
    'highlight' => true,
    'limit' => 20, // 1 to 999
    'sort' => 'relevance' // or 'date'
)
```

Usage
-----

[](#usage)

```
/**
 * Returns PHP object of search results
 * @param $search (string) - what to search for
 * @param $options (array) - set an 'offset' index and/or override any of the defaults set in the config file
 * @return (object) - PHP object (details below)
 */
$apiResult = GovSearch::search($search, $options);
```

#### Sample Format of Returned Object:

[](#sample-format-of-returned-object)

```
{
    "total": 356,
    "next_offset": 20,
    "spelling_correction": null,
    "results": [
        {
            "title": "sample title",
            "url": "http://www.anyplace.com",
            "snippet": "sample snippet",
            "publication_date": "2014-11-24"
        }
    ]
}
```

Basic Search Pagination Example
-------------------------------

[](#basic-search-pagination-example)

```
// Set Defaults
$search = 'Medal of Honor';
$options = array(
    'offset' => 0,
    'limit' => 25
);

// Make initial call
$apiResult = GovSearch::search($search, $options);

// Set total results
$totalResults = $apiResult['total'];

// Set total pages
$totalPages = ceil($totalResults / $options['limit']);

// Using this example, with 77 total results, would give you 4 pages
// If you want to go to page 3 of 4...
$page = 3;
$options['offset'] = ($page - 1) * $options['limit'];
$apiResults = GovSearch::search($search, $options);
```

Credits
-------

[](#credits)

Built on code from Alaouy's [Youtube](https://github.com/alaouy/Youtube) Laravel Facade/Wrapper.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

4052d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c59be98f472c99cb7494dcf8d2d756795d5f6a05fd0da8826030deadbe0f9f5?d=identicon)[iblank](/maintainers/iblank)

---

Top Contributors

[![iblank](https://avatars.githubusercontent.com/u/686766?v=4)](https://github.com/iblank "iblank (1 commits)")

---

Tags

apisearchlaravelgovernmentiblank

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iblank-laravel-gov-search/health.svg)

```
[![Health](https://phpackages.com/badges/iblank-laravel-gov-search/health.svg)](https://phpackages.com/packages/iblank-laravel-gov-search)
```

###  Alternatives

[aerni/laravel-spotify

A Laravel wrapper for the Spotify Web API

209145.6k](/packages/aerni-laravel-spotify)

PHPackages © 2026

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