Skip to content

Commit

Permalink
Adds package auto-discovery. Closes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseconey committed Feb 23, 2018
1 parent 761ef32 commit 99d0a13
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,60 @@ Laravel Datadog Helper helps you get your application metrics integrated into La
* Provides middleware for tracking response time metrics automatically
* Allows prefixing all metrics that are sent for the whole application with common prefix

## Usage
## Installation

### Step 1: Install Through Composer
Require this package with composer.

```
```shell
composer require chaseconey/laravel-datadog-helper
```

### Step 2: Add Service Provider to providers array in app config file.
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you would like to install the request metric tracking middleware, add the Datadog middleware class like so:

``` php

// config/app.php
// app/Http/Kernal.php

'providers' => [
protected $middleware = [
...
ChaseConey\LaravelDatadogHelper\LaravelDatadogHelperServiceProvider::class,

\ChaseConey\LaravelDatadogHelper\Middleware\LaravelDatadogMiddleware::class
];
```

### Step 3: Add Facade
### Without Auto-Discovery (or Laravel < 5.5)

If you don't use auto-discovery, or you are using an older version of Laravel, add the ServiceProvider to the providers array in `config/app.php`

``` php

// config/app.php

'aliases' => [
'providers' => [
...

'Datadog' => ChaseConey\LaravelDatadogHelper\Datadog::class
ChaseConey\LaravelDatadogHelper\LaravelDatadogHelperServiceProvider::class,
];
```

### Step 4: Register Middleware
If you want to use the facade, add this to your facades in `config/app.php`:

``` php

// app/Http/Kernal.php
// config/app.php

protected $middleware = [
'aliases' => [
...

\ChaseConey\LaravelDatadogHelper\Middleware\LaravelDatadogMiddleware::class
'Datadog' => ChaseConey\LaravelDatadogHelper\Datadog::class
];
```

### Step 5: Publish configuration
For configuration options, copy the package config to your local config with the publish command:

```php
```shell
php artisan vendor:publish --provider="ChaseConey\LaravelDatadogHelper\LaravelDatadogHelperServiceProvider"
```

Expand Down
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"ChaseConey\\LaravelDatadogHelper\\LaravelDatadogHelperServiceProvider"
],
"aliases": {
"Datadog": "ChaseConey\\LaravelDatadogHelper\\Datadog"
}
}
}
}

0 comments on commit 99d0a13

Please # to comment.