Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Instantiate Class Using Namespaces in PHP?

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 459
    Answer it

    Trying to figure out how to instantiate class with name spaces. The library was built for Composer to manage dependencies, but we're using just the necessary classes for our project.


    We are using this library:
    https://github.com/thephpleague/oauth2-client


    We have included the /src directory and are attempting to instantiate a class using namespaces as required by the library.

     foreach (glob('src/*.php') as $filename)
    {  
    
        include_once $filename;
    }
    
    $provider = new \League\OAuth2\Client\Provider\GenericProvider([
        'clientId'                => $client_id,    // The client ID assigned to you by the provider
        'clientSecret'            => $client_secret,   // The client password assigned to you by the provider
        'redirectUri'             => 'http://example.com/your-redirect-url/',
        'urlAuthorize'            => 'https://example.com/oauth2/auth',
        'urlAccessToken'          => 'https://example.com/oauth2/token',
        'urlResourceOwnerDetails' => 'https://example.com/oauth2/token'
    ]); 

     

 2 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: