I have added coinbase php library inside application/third_party folder. Now I want to add a normal php file using that library in codeigniter root folder to add content to log file and send email to notify about transactions?
UPDATE: I created a controller in application/controlers with below code
class Coinbase extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->database();
}
function readnotifications()
{
echo APPPATH;
require_once(APPPATH.'third_party/coinbase-php/vendor/autoload.php');
use Coinbase\Wallet\Client;
}
}
I get below error.
Parse error: syntax error, unexpected 'use' (T_USE)
UPDATE2:
$config['composer_autoload'] = APPPATH.'third_party/coinbase-php/vendor/autoload.php';
class Coinbase extends CI_Controller
{
function readnotifications()
{
$apiKey = "sss ";
$apiSecret = "sss";
namespace Coinbase\Wallet;
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Enum\Param;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$authenticity = $client->verifyCallback($raw_body, $signature); // boolean
}
}
Parse error: syntax error, unexpected 'Coinbase' (T_STRING), expecting \ (T_NS_SEPARATOR)
Any idea how to resolve?
In you application/config/config.php search for $config['composer_autoload']
and set you third party package autoload.php file path as its value
$config['composer_autoload'] = '/path/to/vendor/autoload.php';
Then you can simple use any of your package classes like this
function readnotifications()
{
$client = Coinbase\Wallet\Client;
}
Also have a look at this https://www.codeigniter.com/user_guide/general/autoloader.html