Downloads
Stars
Version
This package provides an elegant wrapper for the official Zendesk API php library. It supports creating tickets, retrieving and updating tickets, deleting tickets, etc.
Install this package via Composer using:
composer require homedesignshops/laravel-zendesk
Laravel 5.5+ users: Skip the Service Provider installation below, because the package is configured for Package Discovery.
// config/app.php
'providers' => [
...
Huddle\Zendesk\Providers\ZendeskServiceProvider::class,
...
];
Publish the config file to app/config/zendesk.php
run:
php artisan vendor:publish --provider="HomeDesignShops\Zendesk\ZendeskServiceProvider"
Set your configuration using environment variables in your .env
file:
ZENDESK_SUBDOMAIN
The subdomain part of your Zendesk organisation.
Example: If your organisation domain is https://homedesignshops.zendesk.com, then use homedesignshops as the subdomain
ZENDESK_USERNAME
The username for the authenticating account in your Zendesk organisation.
ZENDESK_TOKEN
The API access token. This can be a basic
token or your oauth
token. You can manage your tokens one at: https://{SUBDOMAIN}.zendesk.com/agent/admin/api/settings
The Zendesk
helper acts as a wrapper for an instance of the Zendesk\API\Client
class.
You can find all the methods available on this class in the
zendesk/zendesk_api_client_php repository. All of the methods
are available through the helper.
<?php
// Get all tickets
zendesk()->tickets()->findAll();
// Create a new ticket
zendesk()->tickets()->create([
'subject' => 'Ticket subject',
'comment' => [
'body' => 'Test ticket content'
],
'priority' => 'normal'
]);
// Update ticket status to urgent
zendesk()->tickets(123)->update([
'status' => 'urgent'
]);
// Delete a ticket
zendesk()->tickets(123)->delete();
<?php
use HomeDesignShops\Zendesk\ZendeskClient;
class TicketsClass {
protected $zendeskClient;
public function __construct(ZendeskClient $zendeskClient) {
$this->zendeskClient = $zendeskClient;
}
public function addTicket() {
$this->zendeskClient->tickets()->create([
'subject' => 'Subject',
'comment' => [
'body' => 'Ticket content.'
],
'priority' => 'normal'
]);
}
}
This package is available under the MIT license.