https://github.com/gregpriday/laravel-serper
A simple wrapper for Serper.dev
https://github.com/gregpriday/laravel-serper
Last synced: 12 months ago
JSON representation
A simple wrapper for Serper.dev
- Host: GitHub
- URL: https://github.com/gregpriday/laravel-serper
- Owner: gregpriday
- License: mit
- Created: 2024-02-29T14:58:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T09:51:23.000Z (almost 2 years ago)
- Last Synced: 2025-02-13T16:36:24.533Z (about 1 year ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Serper Package README
## Introduction
The Laravel Serper package is a simple, efficient wrapper around the [Serper.dev API](https://serper.dev/), designed to integrate seamlessly with Laravel applications. It provides a fluent, expressive interface to perform searches and retrieve news results from Google via Serper.dev, making it easier for developers to include search functionalities in their Laravel applications.
## Features
- Easy-to-use facade for performing searches and retrieving news results.
- Support for single and multiple queries with customizable parameters.
- Integration with Laravel's service container for easy configuration and extension.
- Utilizes GuzzleHttp for efficient HTTP requests.
- Includes a suite of unit tests for reliability and maintainability.
## Installation
To install the Laravel Serper package, run the following command in your terminal:
```bash
composer require gregpriday/laravel-serper
```
After installation, publish the package's configuration file by running:
```bash
php artisan vendor:publish --provider="GregPriday\LaravelSerper\SerperServiceProvider"
```
## Configuration
Before using the Serper package, you must obtain an API key from Serper.dev and add it to your `.env` file:
```plaintext
SERPER_API_KEY=your_serper_dev_api_key
```
Then, configure your API key in the `config/serper.php` configuration file:
```php
return [
'key' => env('SERPER_API_KEY', ''),
];
```
## Usage
The Laravel Serper package provides a simple API to perform search and news queries. Here's how you can use it:
### Performing a Search
To perform a search, use the `Serper::search` method:
```php
use GregPriday\LaravelSerper\Facades\Serper;
$results = Serper::search('Laravel');
```
### Retrieving News Results
To retrieve news results, specify the type as 'news' in the `search` method:
```php
$newsResults = Serper::search('Laravel', 10, 'news');
```
### Performing Multiple Searches
To perform multiple searches at once, use the `Serper::searchMulti` method:
```php
$queries = ['Laravel', 'PHP'];
$results = Serper::searchMulti($queries, 10, 'search');
```
## Testing
This package comes with a suite of PHPUnit tests. To run the tests, use the following command:
```bash
vendor/bin/phpunit
```
## Contribution
Contributions are welcome! Please feel free to submit pull requests or open issues on the GitHub repository.
## License
The Laravel Serper package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).