hoseinrafiei/easy-yelp

A light-weight PHP Client for Yelp Fusion API

1.0.1 2019-01-04 12:56 UTC

This package is auto-updated.

Last update: 2025-06-12 06:24:25 UTC


README

Easy Yelp is a single file PHP client for Yelp API.

Installation

You can simply install it using composer.

composer require hoseinrafiei/easy-yelp

If you're not using composer, you can simply download the file and include it in your project manually.

require 'yelp.php';

Usage

Create an instance and send your API token to the constructor method. Then simply call the methods with proper request and fetch the data from Yelp API Easily.

$yelp = new EasyYelp\Yelp('YOUR_API_TOKEN');
$businesses = $yelp->businessSearch([
    'location' => 'Los Angeles, CA',
    'price' => '1,2,3',
    'sort_by' => 'distance',
    'limit' => '30',
])->getArray();

Methods

Business Search

$request = [];
$yelp->businessSearch($request)->getArray();

Phone Search

$request = [];
$yelp->businessPhoneSearch($request)->getArray();

Transaction Search

$request = [];
$yelp->transactionSearch('delivery', $request)->getArray();

Business Details

$businessId = 'blahblah'; 
$request = [];
$yelp->businessDetails($businessId, $request)->getArray();

Business Match

$request = [];
$yelp->businessMatch($request)->getArray();

Business Reviews

$businessId = 'blahblah';
$request = [];
$yelp->businessReviews($businessId, $request)->getArray();

Autocomplete

$request = [];
$yelp->autocomplete($request)->getArray();

Event Lookup

$eventId = 'blahblah';
$request = [];
$yelp->eventDetails($eventId, $request)->getArray();

Event Search

$request = [];
$yelp->events($request)->getArray();

Featured Event

$request = [];
$yelp->featuredEvent($request)->getArray();

All Categories

$request = [];
$yelp->categories($request)->getArray();

Category Details

$alias = 'blahblah'; 
$request = [];
$yelp->categoryDetails($alias, $request)->getArray();

Examples

You can check examples directory files to see some examples for using API methods.

Errors

To check if you received an error from Yelp API or not you can use following functions.

$businesses = $yelp->businessSearch($request)->getArray();
if($yelp->hasError()) // We have an error
{
    echo $yelp->getError(); // Print the error message
}

License

This software released under MIT License.