Fatal error: Class 'Hybrid_Logger' not fou

2019-05-21 07:00发布

问题:

I am drying to deploy HyBridAuth as a plugin in my website . my fucntion looks something like this .

function authenticatewith( $provider ){
                                    ini_set('display_errors','on');

            //includes

                    $config   = dirname(__FILE__) . '/hybridauth-2.1.2/hybridauth/config.php';
                                require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );

                            $provider_name = $provider;

                            //$config = $this->getconfig($id);
                            try{
                            // initialize Hybrid_Auth with a given file
                            $hybridauth = new Hybrid_Auth( $config );

                            // try to authenticate with the selected provider
                            $adapter = $hybridauth->authenticate( $provider_name );

                            // then grab the user profile 
                            $user_profile = $adapter->getUserProfile();
                            }
                            catch( Exception $e ){
                            echo "Error: please try again!";
                            echo "Original error message: " . $e->getMessage();
                            }

                            echo "USer Details: ";
                            var_dump($user_profile);

            }   

I am running into a fatal error when I try to access any of the provider .

Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php on line 165

I get no links for this problem in stack I though I will raise this here.

Thanks & Regards

回答1:

Before doing anything else, make sure you are using session_start().

Since using session_start() will throw an error of level E_NOTICE if a session has already been started, a better approach would be:

if(session_id() == '') {
    session_start();
}

And keep in mind that if the user's browser does not have cookies enabled, you will have issues with HybridAuth because of the default value of the PHP setting session.use_cookies

session.use_cookies = 1 //PHP uses cookies by default

A beta user for a project I'm working on reported seeing this error - and for a long time I was unable to replicate the error. After long hours of debugging, it turned out to be a browser configuration error that was specific to the user (cookies were disabled). Not sure if it will solve your problem, but it's worth mentioning that the error:

Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php 

Can also be caused due to browser-specific settings (such as disabled cookies).

References:

http://php.net/manual/en/function.session-start.php

http://php.net/manual/en/session.security.php



回答2:

This error occur if you cannot access the config.php or if the base_url is wrong or if you are trying to access the remote application service ( facebook , or else ) from localhost... You should then use a live domaine working online , to do so you have to add the following line to your windows/system32/drivers/etc/hosts if you are under windows and /etc/hosts if you are in unix based system :

127.0.0.1 your-domaine.extension

where extension is one of the following : com , net or anything else that could work

this method is applied if you have not a working domain for your application otherwise you need to specify your www domain for this to work properly...

hope its helpfull



回答3:

I had the exact same error, I discovered that the session global variable didn't have the required values ("CONFIG") and it was because I set the base_url to a different than the one from which I was testing. To be more specific: I was accessing with www.mywebsite.com and the base_url was set to just mywebsite.com. Fixed it by setting base_url to www.mywebsite.com. I also recommend to redirect to www like this: .htaccess - how to force "www." in a generic way?



回答4:

require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );

does not contain the full path like the include of config.php does.



回答5:

Use session_start(); before any other things you do..