Hi,
Excuse me for my naive knowledge of OOP as well as phalcon. Here is the thing, there is a class provided by third party. I wanted to add it to phalcon via composer autoload. And then want to wrap it around my class so that if in future I change that third party, I don' thave to tinker lots of code.
I created my class and added to DI:
/**
* Third Party api
*/
$di->set('thirdpartyapi', function () {
return new ThirdPartyApi();
});
I created my own ThirdPartyApi.php and class with same name in it.
Assuming, theirparty class name is "ThirdPartyProvider", I copied it to vender -> thirdpartyprovider ->src and added following its composer.json
This is folder structure under vendor :
{
"name": "thirdpartyprovider/",
"description": "A third party service",
"autoload": {
"psr-4": {
"ThirdPartyProvier\\": "src/"
}
},
"license": "MIT"
}
Content of ThirdPartyProvder.php
namespace ThirdPartyProvider;
class ThirdPartyProvider
{
private $username;
private $hash;
private $apiKey;
private $errorReporting = false;
.
.
.
.
.
}
Then I ran 'composer dump' to include autoload
Now if I call ThirdPartyApi.php , it fails to load ThirPartyProvider class. Clearly its not being loaded into my class.
Kindly advice how to add third party classes in phalcon with composr autloader.