diff --git a/README.md b/README.md index 5686235..c01e211 100644 --- a/README.md +++ b/README.md @@ -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" ``` diff --git a/composer.json b/composer.json index d3003ab..665730a 100644 --- a/composer.json +++ b/composer.json @@ -42,5 +42,15 @@ }, "config": { "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "ChaseConey\\LaravelDatadogHelper\\LaravelDatadogHelperServiceProvider" + ], + "aliases": { + "Datadog": "ChaseConey\\LaravelDatadogHelper\\Datadog" + } + } } }