Skip to content

Commit

Permalink
Rename Facade to Debugbar (barryvdh#1218)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maritaria authored Nov 4, 2021
1 parent 69f44e7 commit 3e72847
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"Barryvdh\\Debugbar\\ServiceProvider"
],
"aliases": {
"Debugbar": "Barryvdh\\Debugbar\\Facade"
"Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`
Expand Down
12 changes: 4 additions & 8 deletions src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
* @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 changes: 33 additions & 0 deletions src/Facades/Debugbar.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 2 additions & 2 deletions tests/BrowserTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -31,6 +31,6 @@ protected function getPackageProviders($app)
*/
protected function getPackageAliases($app)
{
return ['Debugbar' => Facade::class];
return ['Debugbar' => Debugbar::class];
}
}
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,7 +31,7 @@ protected function getPackageProviders($app)
*/
protected function getPackageAliases($app)
{
return ['Debugbar' => Facade::class];
return ['Debugbar' => Debugbar::class];
}

/**
Expand Down

0 comments on commit 3e72847

Please sign in to comment.