hackalive Posted May 27, 2012 Share Posted May 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/ Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 Apparently it is because I am not using an autoloader ... if anyone can tell me how to setup and configure and auto-loader for Windows with Apache and PHP that would be great Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348881 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 This is the one I need to use apparently: http://getcomposer.org/ But have no idea how to make it work on Windows with Apache and PHP. (FYI - I do have full server access) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348884 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348885 Share on other sites More sharing options...
cpd Posted May 27, 2012 Share Posted May 27, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348890 Share on other sites More sharing options...
requinix Posted May 27, 2012 Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348891 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348892 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348893 Share on other sites More sharing options...
requinix Posted May 27, 2012 Share Posted May 27, 2012 since the require_once is causing errors too. Like what? Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348895 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 either it cant find the file or if i point it more absolute the same error as above. If you download it and give it a try you will see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348896 Share on other sites More sharing options...
cpd Posted May 27, 2012 Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348897 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 As I said before - the developer has said it MUST USE http://getcomposer.org/ not PHP method. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348898 Share on other sites More sharing options...
darkfreaks Posted May 27, 2012 Share Posted May 27, 2012 does storage.pdo.php exist in your directory? that may be your problem Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348901 Share on other sites More sharing options...
cpd Posted May 27, 2012 Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348902 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348904 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 does storage.pdo.php exist in your directory? that may be your problem storagepdo.php in the same directory as what? the vendor folder - the root - what? Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348905 Share on other sites More sharing options...
trq Posted May 27, 2012 Share Posted May 27, 2012 Have you looked at the documentation for composer? It is simple to use. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348907 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 "Intsalling" composer was not hard - getting it and this to work is. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348911 Share on other sites More sharing options...
trq Posted May 27, 2012 Share Posted May 27, 2012 "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? Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348912 Share on other sites More sharing options...
hackalive Posted May 27, 2012 Author Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348914 Share on other sites More sharing options...
trq Posted May 27, 2012 Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348926 Share on other sites More sharing options...
trq Posted May 27, 2012 Share Posted May 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263193-fatal-error-interface/#findComment-1348928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.