Getting started
Omneo PHP is a PHP client library for the Omneo API service. It allows developers to easily integrate Omneo with their PHP applications.
Prerequisites
Before being able to use the package, you will need to get your hands on the following.
Omneo domain This takes the form of
example.omneoapp.io
and is where your Omneo installation lives. If you login to your dashboard atfoo.dashboard.omneo.io
, your Omneo domain isfoo.omneoapp.io
.Omneo token This is the secure token which identifies you to the API. It can be generated from the Omneo dashboard and is associated with your user account. It is advisable that you create a separate Omneo user specifically for your integration.
Shared secret You only need this if you plan on accepting incoming webhook and target requests from Omneo. If so, you will need to validate that it's actually Omneo sending the request by generating and comparing a signature using the shared secret.
Installation
Installation is performed via Composer.
composer require omneo/omneo-php
Quickstart
Plain PHP
// Get credentials, you should store these outside of your codebase
$domain = 'foo.omneoapp.io';
$token = '...';
// Instantiate the Omneo client
$omneo = new Omneo\Client($domain, $token);
// Optional, add the shared secret for verifying webhooks and targets
$omneo->setSecret('horsebatterystaple');
// Use the client to communicate with omneo
$profiles = $omneo->profiles()->browse();
Laravel
This package comes batteries-included for usage with Laravel. To begin, install the package using Composer and update the following files.
'omneo' => [
'domain' => env('OMNEO_DOMAIN'),
'token' => env('OMNEO_TOKEN'),
'secret' => env('OMNEO_SECRET')
]
OMNEO_DOMAIN=
OMNEO_TOKEN=
OMNEO_SECRET=
Now that you're authentication details are set, you can utilise the Omneo package anywhere in your application that has access to the Service Container.
class FooController extends Controller
{
public function getProfiles(Omneo\Client $omneo)
{
// Using typehints
$profiles = $omneo->profiles()->browse();
// Using the app() method
$profiles = app(Omneo\Client::class)->profiles()->browse();
}
}
Last updated