I use barryvdh/laravel-debugbar. How can I display debugbar only for certain people?
Check the documentation here: https://github.com/barryvdh/laravel-debugbar
If you want to enable/disable debugbar at runtime, use this codes:
\Debugbar::enable();
\Debugbar::disable();
You may do something like this. Create a middleware php artisan make:middleware TestMiddleware
, Don't forget to edit app/Http/Kernel.php
and add TestMiddleware
protected $middleware = [
...
\App\Http\Middleware\TestMiddleware::class,
...
];
Then this is your TestMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
class TestMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (auth()->user() && in_array(auth()->id(), [1,2,3])) {
\Debugbar::enable();
}
else {
\Debugbar::disable();
}
return $next($request);
}
}
You can do this in this in Your AppServiceProvider.php
namespace App\Providers;
use Barryvdh\Debugbar\ServiceProvider as Bry;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
}
public function register(){
if($_SERVER['REMOTE_ADDR'] == 'YourIp'){
$this->app->register(Bry::class); // or $this->app->register(new Barryvdh\Debugbar\ServiceProvider());
}
}
By this way you can register ServiceProvider dynamicaly.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With