From e7404b94fe464782abe297ace8f1211fea7c41b0 Mon Sep 17 00:00:00 2001 From: Ben-Piet O'Callaghan Date: Wed, 20 Sep 2017 09:35:08 +0200 Subject: [PATCH] add support for automatic package discovery (Laravel 5.5) --- README.md | 3 ++- composer.json | 9 ++++++++- src/ImpersonateServiceProvider.php | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b923274..a67113a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Laravel 5 package to enable impersonation. Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers. -
See it in action at a [Laravel Admin Starter](https://github.com/bpocallaghan/laravel-admin-starter) project. +See it in action at a [Laravel Admin Starter](https://github.com/bpocallaghan/laravel-admin-starter) project. ## Installation @@ -13,6 +13,7 @@ Update your project's `composer.json` file. composer require bpocallaghan/impersonate --dev ``` +`Laravel <5.4 only (Laravel 5.5 has automatic package discovery)`
Register the Service Provider in your `config/app` or in your `app/Providers/AppServiceProvider.php` to only allow it for development. ```php diff --git a/composer.json b/composer.json index 2ff8b96..e38bb59 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": ">=5.6.4" + "php": ">=7.0.0" }, "autoload": { "psr-4": { @@ -26,5 +26,12 @@ "files": [ "src/helpers.php" ] + }, + "extra": { + "laravel": { + "providers": [ + "Bpocallaghan\\Impersonate\\ImpersonateServiceProvider" + ] + } } } diff --git a/src/ImpersonateServiceProvider.php b/src/ImpersonateServiceProvider.php index 555e375..da47cfa 100644 --- a/src/ImpersonateServiceProvider.php +++ b/src/ImpersonateServiceProvider.php @@ -42,8 +42,8 @@ public function boot() */ public function register() { - $this->app->bind('impersonate', function () { - return $this->app->make('Bpocallaghan\Impersonate\Impersonate'); + $this->app->singleton('impersonate', function () { + return $this->app->make(Impersonate::class); }); } }