So here's the thing. I'm trying to make a small website that will use an ontology stored on a Sesame Server. I found this (https://github.com/labxxi/phpsesame ) library, put it into my custom directory in app/Libraries and namespaced it. All is fine there. To use that PhpSesame library you need HTTP_Request2 (https://pear.php.net/package/HTTP_Request2 ) and semsol/ARC2 (https://github.com/semsol/arc2 ). Installing ARC2 was simple, update composer.json and do composer update. However, HTTP_Request2 requires you to install PEAR and then install it through PEAR. I believe I have done that but if I try to use phpSesame I get this: FatalErrorException in phpSesame.php line 156: Class 'App\Libraries\HTTP_Request2' not found.
If I look up the usability of HTTP_Request2 it basically says that you need to have "require_once 'HTTP/Request2.php';" in your code to use it which the phpSesame seem to have. My guess is that the fact that I'm doing this on a framework is what's causing issues which brings me here. Any ideas?
You mentioned you changed the namespace of the library you are using.
This means you will need to import every class the library uses with a use statement (including HTTP_Request2) or use the fully qualified classname (just prefix with \ if it is in the global namespace).
I remembered that when doing this with composer requires further tinkering with the app.php in the config folder which kinda melted my mind while trying to resolve it... What should I enter in the providers and aliases areas when I add packages like these in?
If you want one all a service provider would need to do is return an instance of the class which you would create the same way you would without laravel.
In the register method of a service provider:
$this->app->bind('PhpSesame', function($app){
return new PhpSesame(/* parameters */);
});
If you aren't going to be passing the same arguments to the constructor each time you would skip the service provider completely and just create a new instance when you need one just like you can with any class.
You can create a facade if you want to but if you aren't going to use it don't bother.
I had the same problem, the fix was the following:
install via composer: composer require pear/http_request2
since release 2.4 composer installation relies completely on autoloading and does not contain require_once calls or use include-path option, in your file, make sure you make use of this file: