Git Product home page Git Product logo

Comments (8)

osmanzeki avatar osmanzeki commented on July 19, 2024 6

Hey everyone!

I was able to fix this by making sure the plugin can make use of Laravel Debugbar's config files to ignore the missing auth class that is causing these exceptions.

Since you can't use php artisan publish in OctoberCMS you have to cheat a little bit by providing a own config.php where you copy the contents of Laravel Debugbar's debugbar.php options and write them into the namespace of the package in October at runtime. If you guys think this fix is good enough, I can make a PR. Let me know if you guys think I forgot anything. Here goes!

Steps to follow to fix the issue

Adding Laravel Debugbar's config file to the Plugin

  1. Install the plugin as you usually do (composer or marketplace, up to you).

  2. After the installation has completed, go to the plugin's vendor folder and copy the contents of Laravel Debugbar's config file. It can usually be found at this location : /plugins/bedard/debugbar/vendor/barryvdh/laravel-debugbar/config/debugbar.php.

  3. Go to the root of this plugin's folder and create a new folder called config.

  4. In this folder create a new file name config.php.

  5. Paste the contents of the debugbar.php file into the new config.php file as is.

You should now have a file at the following location with the contents of the Laravel Debugbar's config file :

/plugins/bedard/debugbar/config/config.php

Loading the config file at runtime

  1. Edit /plugins/bedard/debugbar/Plugin.php.

  2. Add this namespace at the top of the file :

use Config;
  1. Add these lines to your the boot function:
// Setup configurations
$config = Config::get('bedard.debugbar::config');
if (!is_null($config)) {
    Config::set('debugbar', $config);
}

Your boot function should now look something like this :

/**
 * Register service provider, Twig extensions, and alias facade.
 */
public function boot()
{
    // Service provider
    App::register('\Barryvdh\Debugbar\ServiceProvider');

    // Setup configurations
    $config = Config::get('bedard.debugbar::config');
    if (!is_null($config)) {
        Config::set('debugbar', $config);
    }

    // Register alias
    $alias = AliasLoader::getInstance();
    $alias->alias('Debugbar', '\Barryvdh\Debugbar\Facade');

    // Register middleware
    if (\Config::get('app.debugAjax', false)) {
        $this->app['Illuminate\Contracts\Http\Kernel']->pushMiddleware('\Bedard\Debugbar\Middleware\Debugbar');
    }

    Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) {
        // Only show for authenticated backend users
        if (!BackendAuth::check()) {
            Debugbar::disable();
        }

        // Twig extensions
        $twig = $controller->getTwig();
        if (!$twig->hasExtension(\Barryvdh\Debugbar\Twig\Extension\Debug::class)) {
            $twig->addExtension(new \Barryvdh\Debugbar\Twig\Extension\Debug($this->app));
            $twig->addExtension(new \Barryvdh\Debugbar\Twig\Extension\Stopwatch($this->app));
        }
    });
}

Fixing the exceptions

Now that all this is done, you can go edit your local /plugins/bedard/debugbar/config/config.php and set the auth loading option that is causing the exceptions to false as follows :

    // ...

    /*
    |--------------------------------------------------------------------------
    | DataCollectors
    |--------------------------------------------------------------------------
    |
    | Enable/disable DataCollectors
    |
     */

    'collectors' => [
        // ...
        'auth' => false, // Display Laravel authentication status
        // ...
    ],

    // ...

from debugbar-plugin.

tientamle avatar tientamle commented on July 19, 2024 2

Replace every steps above, for easier to fix it, just edit the file:

/plugins/bedard/debugbar/Plugin.php

and add the code below on top of the boot() function:

$config = \Config::get('debugbar', []);
if (isset($config['collectors']['auth'])) {
    $config['collectors']['auth'] = false;
    $config = \Config::set('debugbar', $config);
}

from debugbar-plugin.

zenzillo avatar zenzillo commented on July 19, 2024

I had the same exceptions and I was able to fix it with this code in the file:

plugins/bedard/debugbar/barryvdh/laravel-debugbar/src/LaravelDebugbar.php

Now I get these errors and I don't know how to fix it...

Cannot add AuthCollector to Laravel Debugbar: Class auth does not exist /.../plugins/bedard/debugbar/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php#454

Class auth does not exist /.../vendor/laravel/framework/src/Illuminate/Container/Container.php#752

Can someone help? Has anyone seen this before?

I am using OctoberCMS 434, PHP 7.0 and Debugbar 2.0.0

from debugbar-plugin.

GinoPane avatar GinoPane commented on July 19, 2024

Is this plugin abandoned?

from debugbar-plugin.

zenzillo avatar zenzillo commented on July 19, 2024

I hope not! It's a great plugin, and I am still using it despite the errors.

from debugbar-plugin.

eXpl0it3r avatar eXpl0it3r commented on July 19, 2024

There's always the option to fix the issues yourself and send in a pull request. 😉

from debugbar-plugin.

scottbedard avatar scottbedard commented on July 19, 2024

Sorry, I've been focused on other projects and haven't had time to dig into this. I like @eXpl0it3r's suggestion though, I'd happily accept a PR that addressed this issue :)

from debugbar-plugin.

empower-josh avatar empower-josh commented on July 19, 2024

I was able to clean this up by using the suggestion provided by @tientamle along with editing:
.../plugins/bedard/debugbar/vendor/barryvdh/laravel-debugbar/config/debugbar.php
and setting collectors['auth'] to 'false'. (line 196 in my case).

from debugbar-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.