0

After testing my site locally with Xampp on windows everyhing works ok. The site is build with Grav. PHP version 8.2.0 on Xampp, 8.2.6 online However after puting it online it gives the follopwing error:

Return value of Grav\Plugin\ProblemsPlugin::autoload() must be an instance of Composer\Autoload\ClassLoader, int returned

I already saw a question posted related to autoload() so hope to find an answer here.

I do have other Grav sites running, but never got this error. If this is not the right place to ask this question, just let me know. Ithought it might by php related and not directly related to Grav

Thanks!

I did change the php version to other versions but that did not solve it. I installed it by copying all the files to a complete empty server. Looked at a related question about autoload() on Stack Overflow

Error log says it comes from the line $instance->setAutoloader($instance->autoload()); In the file Plugins.php

   public function init()
    {
        if ($this->plugins_initialized)  {
            return $this->items;
        }

        $grav = Grav::instance();

        /** @var Config $config */
        $config = $grav['config'];

        /** @var EventDispatcher $events */
        $events = $grav['events'];

        foreach ($this->items as $instance) {
            // Register only enabled plugins.
            if ($config["plugins.{$instance->name}.enabled"] && $instance instanceof Plugin) {
                // Set plugin configuration.
                $instance->setConfig($config);
                // Register autoloader.
                if (method_exists($instance, 'autoload')) {
                    $instance->setAutoloader($instance->autoload());
                }
                // Register event listeners.
                $events->addSubscriber($instance);
            }
        }
8
  • As you haven't shared the code, it's impossible to provide help
    – Nico Haase
    Commented Sep 29, 2023 at 11:06
  • Added some code. Hope it is the right part
    – Richard
    Commented Sep 29, 2023 at 11:28
  • And what does $instance->autoload() return? Check that further, I would assume that (as given in the error message) any of the plugins returns a number
    – Nico Haase
    Commented Sep 29, 2023 at 11:56
  • How can I check that?
    – Richard
    Commented Sep 29, 2023 at 12:24
  • You could start by dumping get_class($instance) to see which plugin causes the problem
    – Nico Haase
    Commented Sep 29, 2023 at 12:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.