1. Go to this page and download the library: Download bestcompany/bestcompany-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bestcompany / bestcompany-api example snippets
use Bestcompany\BestcompanyApi\BestcompanyApi;
$api = BestcompanyApi::create([
'key' => 'your_api_key',
'hostname' => 'https://api.bestcompany.com/api',
'version' => 'v1'
]);
// Company operations
$companies = $api->companies()->all();
$company = $api->companies()->get(123);
// Review operations
$reviews = $api->reviews()->all();
$review = $api->reviews()->get(456);
// Other available resources
$api->verticals()->all();
$api->factSheets()->all();
$api->companyReviewLists()->all();
use Bestcompany\BestcompanyApi\BestcompanyApi;
use Bestcompany\BestcompanyApi\SnoballApi;
class CompanyController extends Controller
{
public function __construct(
private BestcompanyApi $bestcompanyApi,
private SnoballApi $snoballApi
) {}
public function getCompanies()
{
$companies = $this->bestcompanyApi->companies()->all();
return response()->json($companies);
}
public function createReferral(Request $request)
{
$referral = $this->snoballApi->referralRequest()->create($request->all());
return response()->json($referral);
}
}
// In your config/app.php aliases array:
'aliases' => [
'BestcompanyApi' => Bestcompany\BestcompanyApi\BestcompanyApiFacade::class,
'SnoballApi' => Bestcompany\BestcompanyApi\SnoballApiFacade::class,
]
// Then use directly:
use BestcompanyApi;
use SnoballApi;
$companies = BestcompanyApi::companies()->all();
$referrals = SnoballApi::referralRequest()->all();
// This will throw a BadMethodCallException:
$bestcompanyApi->referralRequest(); // ❌ Not available in BestcompanyApi
// This will throw a BadMethodCallException:
$snoballApi->companies(); // ❌ Not available in SnoballApi
use Bestcompany\BestcompanyApi\Exceptions\SnoballApiException;
try {
$referralRequest = SnoballApi::referralRequest()->create($params);
} catch (SnoballApiException $e) {
if ($e->hasFieldErrors()) {
// Per-field validation errors, keyed by input name — map onto your form.
return back()->withErrors($e->fieldErrors());
}
if ($e->isUserSafe()) {
// The server marked this message safe to show the person filling out the form.
return back()->with('error', $e->displayMessage());
}
// Config/server problem — log it and show a generic message.
report($e);
return back()->with('error', 'Something went wrong — please contact support.');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.