Jump to content

Fatal error: Interface


hackalive

Recommended Posts

Hi guys,

I've implemented this library https://github.com/zircote/oauth2-php

 

However when visiting authorize.php (or any page using 'A:\public\OAuth2\Storage\StoragePdo.php')  I get the following error:"

Fatal error: Interface 'OAuth2\Grant\GrantCodeInterface' not found in A:\public\OAuth2\Storage\StoragePdo.php on line 25

 

The relevant code from A:\public\OAuth2\Storage\StoragePdo.php is:

<?php
/**
* @category OAuth2
* @package  OAuth2
* @file
* Sample OAuth2 Library PDO DB Implementation.
*
* Simply pass in a configured PDO class, eg:
* new OAuth2StoragePDO( new PDO('mysql:dbname=mydb;host=localhost', 'user', 'pass') );
*/
namespace OAuth2\Storage;
use OAuth2\Grant\GrantCodeInterface,
    OAuth2\RefreshTokensInterface,
    PDOException,
    PDO;

/**
* PDO storage engine for the OAuth2 Library.
*
* IMPORTANT: This is provided as an example only. In production you may implement
* a client-specific salt in the OAuth2StoragePDO::hash() and possibly other goodies.
*
*** The point is, use this as an EXAMPLE ONLY. ***
*/
class StoragePdo implements GrantCodeInterface, RefreshTokensInterface {

 

If anyone can tell me why this is happening and how to fix it that would be greatly appreciated.

 

Cheers

Link to comment
Share on other sites

This will show you how to set-up an autoloader in PHP. Its definitely not a lot of hassle in the slightest and well worth doing in the long run.

 

That said it may not be the cause of your issue. There's a lot of namespaces, have you confirmed your using the right namespace for the file you want to use?

Link to comment
Share on other sites

Actually - forget all of the above

 

Can someone just tell me how to change the code to not use an auto-loader at all - decided more hassle than its worth.

 

Thanks

require_once() the relevant files.

 

Unfortunately this is not working either - if you can suggest how to make it work that would be great :)

Link to comment
Share on other sites

This will show you how to set-up an autoloader in PHP. Its definitely not a lot of hassle in the slightest and well worth doing in the long run.

 

That said it may not be the cause of your issue. There's a lot of namespaces, have you confirmed your using the right namespace for the file you want to use?

 

I cannot get it to work, so if you can tell me how to make it all work then I gladly will, since the require_once is causing errors too.

Link to comment
Share on other sites

Its very simple and the examples on the PHP website can't really get any better.

 

Define a function as they have with a parameter called $class or similar. Define inside the function all the possible class locations and then cycle through each one appending the $class variable - as shown in the examples - testing if the file exists. If it does, include it.

Link to comment
Share on other sites

Throw it all in the bin and write your own stuff. Cba with fiddly things like that, you spend more time figuring out how to use the bloody thing. An autoload function can be defined in minutes but whatevs.

Link to comment
Share on other sites

Throw it all in the bin and write your own stuff. Cba with fiddly things like that, you spend more time figuring out how to use the bloody thing. An autoload function can be defined in minutes but whatevs.

 

For an oAUth library? That will take too long

Link to comment
Share on other sites

"Intsalling" composer was not hard - getting it and this to work is.

 

If you expect us to be able to help you we are going to need more details than that simple comment. What exactly is the issue?

Link to comment
Share on other sites

thorpe - to be blunt and simple - no one has said how to get it to work with this code and where to but vendor data or includes.

So simply put it does not work at all.

 

Ive put composer.phar and .json in the php folder - run the composer phar install

its created the vendor folder

I put the vendor folder outside of the webroot - then what - does not matter where i put this folder it does not work - how do i link it to the libraries etc?

 

thorpe - if you could take the time to clearly layout the process I need to undertake that would be fantastic.

Link to comment
Share on other sites

Composer is used to package dependencies for an application or library. eg; You want to use library Foo, library Foo depends upon LibA and LibB.

 

You download Foo and install it's dependencies using composer.

 

The issue you are having seems unrelated. You are trying to use a library without including all the files that that library (and your code) needs. On top of that, Iv'e just had a look at the library your using and it's composer file does not actually require any outside dependencies, so there is no need to run composer on it at all. The composer.json file is only there (in this case) so that this library can be easily included into other libraries.

 

If your not willing to use an autoloader (any PSR-0 compliant one will work) then you are going to need to require any files you need to use manually. I'm really not sure what the issue is.

Link to comment
Share on other sites

Oh, and ps: The autoloader in my framework (Proem) is PSR-0 compliant. If you want a simple solution download my framework (link in my signature), include the autoloader into your code, then register the OAuth2 namespace with the autoloader by telling it the root of the namespace and the directory it can find it. eg;

 

<?php

require_once "/path/to/Proem/lib/Autoloader.php";

$loader = new \Proem\Autolader;
$loader->registerNamespace('OAuth2', 'path/to/OAuth2/library')->register();

// You should now be able to use the OAuth2 library here.

 

Proem does require PHP5.4 however. Many other frameworks have PSR-0 compliant autoloaders including Symfony2 and Zend2. Even the link to the PSR-0 page I provided has a very simple implementation.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.