I am using ZendOAuth to authenticate with an OAuth authentication. I have installed the package and all it dependencies using composer. But when I try to use this code, it can't find the Zend classes.
I use the following example code to test if the OAuth is working:
$consumer = new Zend_Oauth_Consumer($this->options);
$token = $consumer->getRequestToken();
echo $token;
When I execute the code I get an error telling me that the class Zend_Oauth_Consumer could not be found.
I am sure my composer packages are correctly loaded because all other packages work fine.
Can someone tell me if I am forgetting something? Do I need an extra include or use?
There is no such class in the library. I think you mean:
$consumer = new \ZendOAuth\Consumer($this->options);
Related
all. I've installed HybridAuth 3.0 and went step-by-step through the Install instructions using composer. I've used the example code and am able to get an initial HybridAuth class instantiated. However, when I continue on to the example with using the Facebook provider class, I'm getting the error, "Class 'Hybridauth\Hybridauth\Provider\Facebook' not found". I'm also using this in a Drupal 7 environment but have other classes like this that autoload just fine so I'm hopeful that little extra detail has no bearing on the problem.
I tried this both with the composer autoloader and the basic autoloader included with the library (as described in the Installation instructions). They both have the same error when attempting to find the Facebook class which is down in the /src/Provider directory. It does this for other classes as well.
That said, using the Hybridauth\Hybridauth "unified interface" works fine and is my current workaround as it allows one to work with multiple providers at one time. But I'm wondering what I'm doing wrong to not be able to load a specific provider as shown in their Introduction documentation.
This works:
// Include Composer's autoloader
include 'vendor/autoload.php';
// Import Hybridauth's namespace
use Hybridauth\Hybridauth;
// Now we may proceed and instantiate Hybridauth's classes
$instance = new Hybridauth([ /* ... */ ]);
This gives an error:
// Include Composer's autoloader
include 'vendor/autoload.php';
// Import Hybridauth's namespace
use Hybridauth\Hybridauth;
$adapter = new Hybridauth\Provider\Facebook([ /* ... */ ]);
I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.
I have installed EDI Library through composer command.
Library Link.
https://github.com/php-edifact/edifact
But in this, they did not give how to register your library in App file.
So can please help me how to register it. They are giving examples of how to use this.
I am just writing simple code.
$x = [1,5,8,9];
$c = new Parser($x);
But the above code is giving an error.
Class 'Parser' not found
Try using new EDI\Parser($x). You need to tell php in what namespace to find the class you are looking for.
Run this command in your command prompt
composer require sabas/edifact
Use in the top of the file like:
namespace EDITest;
use EDI\Parser;
If you have the time to read the firebase-php documentation, you can see there how to use the helper library to "connect" to firebase. But unfortunately, I think that the connection could only be established by phpunit, in other words, output can only be seen in the terminal. Since when you run the php pages in your browser, it will return fatal errors. Does anyone know how to use the helper library to connect to the firebase data without using phpunit? Thank you in advance.
Using the lib is very easy, when you just look at the source code of the tests.
There are two kinds of tests:
a real functionality test, which uses cURL requests to the server and therefore is slow during testing with PHPUnit
a mocked functionality test (stub), which simulates the connection to and the response from the server, which is faster during testing
Now, in order to use firebase-php, you would simply do the same things as in the real functionality test. Include the lib, prepare the connection object with login credentials and then call the method you want. The interface describes, which methods you can expect in the firebaseLib class -
or just look at the lib source itself.
This piece of code should get you started:
require '/path/to/libs/firebase-php/firebaseLib.php';
$url = '...';
$token = '...';
$firebase = new Firebase($url, $token);
$firebase->get('something/from/somewhere');
If you fetch the library via composer, you might declare an autoloading classmap, too. The author hasn't done this, yet.
{
"autoload": {
"classmap": ["vendor/ktamas77/firebase-php/firebaseLib.php"]
}
}
Then simply require Composer's Autoloader with require "vendor/autoload.php"; and new Firebase to autoload the class.
How to get the auth token
open your firebase console
go to project settings
go to the database
then copy the secret key
I am developing an oAuth 2.0 server using thephpleague library provided by Alex Bilbie. But, after the initializing the authorization server, when I declare the storage classes it throws an following error.
"Fatal error: Class 'Storage\SessionStorage' not found"
Please help me to resolve this. I read your post about this problem here:- Guide me implementing Oauth2 PHP server using thephpleague library
Please let me know how can I implement the storage classes. My current code:
require_once "/../vendor/autoload.php";
$server = new \League\OAuth2\Server\AuthorizationServer;
$server->setSessionStorage(new Storage\SessionStorage);
$server->setAccessTokenStorage(new Storage\AccessTokenStorage);
$server->setClientStorage(new Storage\ClientStorage);
$server->setScopeStorage(new Storage\ScopeStorage);
$server->setAuthCodeStorage(new Storage\AuthCodeStorage);
$authCodeGrant = new \League\OAuth2\Server\Grant\AuthCodeGrant();
$server->addGrantType($authCodeGrant);
The library that you use requires implementing your own storage classes, see http://oauth2.thephpleague.com/implementing-storage-interfaces/. The class names that you use are from an example implementation https://github.com/thephpleague/oauth2-server/tree/master/examples/relational/Storage that uses Capsule as its storage backend. If you want to use Capsule as you backend, you'll need to download those example implementation classes and install https://github.com/illuminate/database.