Rename Facade to Debugbar (#1218)

Creating the facade as a class named Debugbar enables better auto completion for IDEs and the like.
To avoid naming conflicts it exists in a separate folder Facades.

For backwards compatibility of existing code the current Facade persists as a class that extends the Debugbar facade class. This should allow for a minor update to the package with a deprecation notice on existing code importing the Facade explicitly.
This commit is contained in:
Maritaria 2021-11-04 13:32:31 +01:00 committed by GitHub
parent 69f44e74f4
commit 3e72847500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 15 deletions

View File

@ -48,7 +48,7 @@
"Barryvdh\\Debugbar\\ServiceProvider"
],
"aliases": {
"Debugbar": "Barryvdh\\Debugbar\\Facade"
"Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
}
}
},

View File

@ -38,7 +38,7 @@ And the default collectors:
- MemoryCollector
- ExceptionsCollector
It also provides a Facade interface for easy logging Messages, Exceptions and Time
It also provides a facade interface (`Debugbar`) for easy logging Messages, Exceptions and Time
## Installation
@ -65,7 +65,7 @@ Barryvdh\Debugbar\ServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
```php
'Debugbar' => Barryvdh\Debugbar\Facade::class,
'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,
```
The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (`debugbar.enabled`) or by setting `DEBUGBAR_ENABLED` in your `.env`. See more options in `config/debugbar.php`

View File

@ -20,15 +20,11 @@ use DebugBar\DataCollector\DataCollectorInterface;
* @method static void warning(mixed $message)
* @method static mixed measure(string $label, \Closure $closure)
*
* @deprecated Renamed to \Barryvdh\Debugbar\Facades\Debugbar
* @see \Barryvdh\Debugbar\Facades\Debugbar
*
* @see \Barryvdh\Debugbar\LaravelDebugbar
*/
class Facade extends \Illuminate\Support\Facades\Facade
class Facade extends \Barryvdh\Debugbar\Facades\Debugbar
{
/**
* {@inheritDoc}
*/
protected static function getFacadeAccessor()
{
return LaravelDebugbar::class;
}
}

33
src/Facades/Debugbar.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace Barryvdh\Debugbar\Facades;
use DebugBar\DataCollector\DataCollectorInterface;
/**
* @method static LaravelDebugbar addCollector(DataCollectorInterface $collector)
* @method static void addMessage(mixed $message, string $label = 'info')
* @method static void alert(mixed $message)
* @method static void critical(mixed $message)
* @method static void debug(mixed $message)
* @method static void emergency(mixed $message)
* @method static void error(mixed $message)
* @method static LaravelDebugbar getCollector(string $name)
* @method static bool hasCollector(string $name)
* @method static void info(mixed $message)
* @method static void log(mixed $message)
* @method static void notice(mixed $message)
* @method static void warning(mixed $message)
*
* @see \Barryvdh\Debugbar\LaravelDebugbar
*/
class Debugbar extends \Illuminate\Support\Facades\Facade
{
/**
* {@inheritDoc}
*/
protected static function getFacadeAccessor()
{
return LaravelDebugbar::class;
}
}

View File

@ -2,7 +2,7 @@
namespace Barryvdh\Debugbar\Tests;
use Barryvdh\Debugbar\Facade;
use Barryvdh\Debugbar\Facades\Debugbar;
use Barryvdh\Debugbar\ServiceProvider;
class BrowserTestCase extends \Orchestra\Testbench\Dusk\TestCase
@ -31,6 +31,6 @@ class BrowserTestCase extends \Orchestra\Testbench\Dusk\TestCase
*/
protected function getPackageAliases($app)
{
return ['Debugbar' => Facade::class];
return ['Debugbar' => Debugbar::class];
}
}

View File

@ -2,7 +2,7 @@
namespace Barryvdh\Debugbar\Tests;
use Barryvdh\Debugbar\Facade;
use Barryvdh\Debugbar\Facades\Debugbar;
use Barryvdh\Debugbar\ServiceProvider;
use Illuminate\Routing\Router;
use Orchestra\Testbench\TestCase as Orchestra;
@ -31,7 +31,7 @@ class TestCase extends Orchestra
*/
protected function getPackageAliases($app)
{
return ['Debugbar' => Facade::class];
return ['Debugbar' => Debugbar::class];
}
/**