Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit 8c7af56

Browse files
authored
Merge pull request #7 from eblin/master
Laravel 5.2+ Support
2 parents b499075 + a5e2ed6 commit 8c7af56

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.4.0",
15-
"illuminate/support": "5.2.*",
15+
"illuminate/support": "~5.2",
1616
"zendesk/zendesk_api_client_php": "2.*"
1717
},
1818
"autoload": {

readme.md

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,70 @@
22

33
This package provides integration with the Zendesk API. It supports creating tickets, retrieving and updating tickets, deleting tickets, etc.
44

5-
The package simply provides a ```Zendesk``` facade that acts as a wrapper to the [zendesk/zendesk_api_client_php](https://github.com/zendesk/zendesk_api_client_php) package.
5+
The package simply provides a `Zendesk` facade that acts as a wrapper to the [zendesk/zendesk_api_client_php](https://github.com/zendesk/zendesk_api_client_php) package.
66

77
**NB:** Currently only supports token-based authentication.
88

99
## Installation
1010

11-
Install via composer by adding the following to your composer.json:
11+
You can install this package via Composer using:
1212

13-
```json
14-
...
15-
"require": {
16-
"huddledigital/zendesk-laravel": "~2.0"
17-
}
18-
...
13+
```bash
14+
composer require huddledigital/zendesk-laravel
1915
```
2016

21-
Add service provider to ```config/app.php```:
17+
You must also install the service provider.
2218

2319
```php
20+
// config/app.php
21+
'providers' => [
2422
...
25-
'Huddle\Zendesk\Providers\ZendeskServiceProvider',
23+
Huddle\Zendesk\Providers\ZendeskServiceProvider::class,
2624
...
25+
];
2726
```
2827

29-
Add alias to ```config/app.php```:
28+
If you want to make use of the facade you must install it as well.
3029

3130
```php
32-
...
33-
'Zendesk' => 'Huddle\Zendesk\Facades\Zendesk',
34-
...
31+
// config/app.php
32+
'aliases' => [
33+
..
34+
'Zendesk' => Huddle\Zendesk\Facades\Zendesk::class,
35+
];
3536
```
3637

3738
## Configuration
3839

39-
Set your configuration using **environment variables**, either in your ```.env``` file or on your server's control panel:
4040

41-
- ```ZENDESK_SUBDOMAIN``` - the subdomain part of your Zendesk organisation URL e.g. if your URL is http://huddledigital.zendesk.com use ```huddledigital```
42-
- ```ZENDESK_USERNAME``` - the username for the authenticating account.
43-
- ```ZENDESK_TOKEN``` - the access token. To generate an access token within Zendesk, click on Settings, API, enable Token Access and click 'add new token'.
41+
To publish the config file to `app/config/zendesk-laravel.php` run:
42+
43+
```bash
44+
php artisan vendor:publish --provider="Huddle\Zendesk\Providers\ZendeskServiceProvider"
45+
```
46+
47+
48+
Set your configuration using **environment variables**, either in your `.env` file or on your server's control panel:
49+
50+
- `ZENDESK_SUBDOMAIN`
51+
52+
The subdomain part of your Zendesk organisation URL.
53+
54+
e.g. http://huddledigital.zendesk.com use **huddledigital**
55+
56+
- `ZENDESK_USERNAME`
57+
58+
The username for the authenticating account.
59+
60+
- `ZENDESK_TOKEN`
61+
62+
The API access token. You can create one at: `https://SUBDOMAIN.zendesk.com/agent/admin/api/settings`
4463

4564
## Usage
4665

4766
### Facade
4867

49-
The ```Zendesk``` facade acts as a wrapper for an instance of the ```Zendesk\API\Client``` class. Any methods available on this class ([documentation here](https://github.com/zendesk/zendesk_api_client_php#usage)) are available through the facade. for example:
68+
The `Zendesk` facade acts as a wrapper for an instance of the `Zendesk\API\Client` class. Any methods available on this class ([documentation here](https://github.com/zendesk/zendesk_api_client_php#usage)) are available through the facade. for example:
5069

5170
```php
5271
// Get all tickets
@@ -72,7 +91,7 @@ Zendesk::ticket(123)->delete();
7291

7392
### Dependency injection
7493

75-
If you'd prefer not to use the facade, you can skip adding the alias to ```config/app.php``` and instead inject ```Huddle\Zendesk\Services\ZendeskService``` into your class. You can then use all of the same methods on this object as you would on the facade.
94+
If you'd prefer not to use the facade, you can skip adding the alias to `config/app.php` and instead inject `Huddle\Zendesk\Services\ZendeskService` into your class. You can then use all of the same methods on this object as you would on the facade.
7695

7796
```php
7897
<?php

src/Providers/ZendeskServiceProvider.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Huddle\Zendesk\Providers;
22

3+
use Huddle\Zendesk\Services\ZendeskService;
34
use Zendesk;
45
use Illuminate\Support\ServiceProvider;
56

@@ -18,9 +19,16 @@ class ZendeskServiceProvider extends ServiceProvider {
1819
* @return void
1920
*/
2021
public function register() {
22+
$packageName = 'zendesk-laravel';
23+
$configPath = __DIR__.'/../../config/zendesk-laravel.php';
24+
2125
$this->mergeConfigFrom(
22-
__DIR__.'/../../config/zendesk-laravel.php', 'zendesk-laravel'
26+
$configPath, $packageName
2327
);
28+
29+
$this->publishes([
30+
$configPath => config_path(sprintf('%s.php', $packageName)),
31+
]);
2432
}
2533

2634
/**
@@ -30,17 +38,7 @@ public function register() {
3038
*/
3139
public function boot()
3240
{
33-
$this->app->bind('zendesk','Huddle\Zendesk\Services\ZendeskService');
34-
}
35-
36-
/**
37-
* Get the services provided by the provider.
38-
*
39-
* @return array
40-
*/
41-
public function provides()
42-
{
43-
return array();
41+
$this->app->bind('zendesk', ZendeskService::class);
4442
}
4543

4644
}

0 commit comments

Comments
 (0)