getgrav / grav-plugin-login

Grav Login Plugin
http://getgrav.org
MIT License
44 stars 54 forks source link

Class 'Grav\Plugin\Login\Login' not found #142

Closed loranger closed 6 years ago

loranger commented 6 years ago

Hello,

I try to install a brand new grav for a brand new project, but it finishes with this weird exception…

Here are the steps I use to reproduce the issue :

$ composer create-project getgrav/grav brandnewgrav

At this step, everything works flawlessly, Grav is installed an running on my local setup (http://brandnewgrav.my.mac)

Then I install the login plugin (Actually I need the admin plugin, but in order to reproduce the issue, I did focus on login) :

$ bin/gpm install login

Login plugin is now installed (such as From and Email dependancies), caches are cleared, and system.yml is touched.

I go back to my grav homepage and then it's broken :

/Users/loranger/Developer/projects/brandnewgrav/user/plugins/login/login.php

         * [onPluginsInitialized] Initialize login plugin if path matches.
         * @throws \RuntimeException
         */
        public function initializeSession()
        {
            // Check to ensure sessions are enabled.
            if (!$this->config->get('system.session.enabled')) {
                throw new \RuntimeException('The Login plugin requires "system.session" to be enabled');
            }

            // Autoload classes
            $autoload = __DIR__ . '/vendor/autoload.php';
            if (!is_file($autoload)) {
                throw new \RuntimeException('Login Plugin failed to load. Composer dependencies not met.');
            }
            require_once $autoload;

            // Define login service.
            $this->grav['login'] = function (Grav $c) {
                return new Login($c);
            };

            // Define current user service.
            $this->grav['user'] = function (Grav $c) {
                $session = $c['session'];

                if (empty($session->user)) {
                    $session->user = $c['login']->login(['username' => ''], ['remember_me' => true, 'remember_me_login' => true]);
                }

                return $session->user;
            };
        }

        /**
         * [onPluginsInitialized] Initialize login plugin if path matches.
         * @throws \RuntimeException
         */
        public function initializeLogin()
        {

Arguments

    "Class 'Grav\Plugin\Login\Login' not found"

I took a look at the login.php page and everything seems correct, the use Grav\Plugin\Login\Login; is in the PHP header, the Login class exists in the Grav\Plugin\Login namespace, I don't get what's wrong.

I also tried a composer dump, but nothing changed.

I use homebrewed nginx 1.12.1 and php-fpm 7.0.26 under macOS 10.13.2

What did I miss ?

davvilla commented 6 years ago

I had the same issue when deploying to heroku (could not reproduce on local). Oddly, what solved it for me was changing my bin/grav install to bin/grav install -n -s. Not sure why it fixed it, my guess is either the symbolic links or that it skipped any prompts.

Let me know if you find more info

loranger commented 6 years ago

I don't know what happened, but now it works… I did upgrade my php to 7.1 and had to restart my mac, so I can't tell what made it work, but it does.

Before all of this, I tried bin/gpm install -n (I did not have to use bin/grav install, but gpm instead) but it didn't work either :/