Issue
I must be making a simple error, I have not used Composer before now. I have followed the instructions on the GitHub page, but I'm getting a Class 'ZCRMRestClient' not found error when I load the page.
composer.json:
{
"require": {
"zohocrm/php-sdk": "^2.0"
}
}
PHP is
require 'vendor/autoload.php';
$configuration = array(
'client_id' => '1000.***',
'client_secret' => '***',
'redirect_uri' => '***',
'currentUserEmail' => '***',
);
ZCRMRestClient::initialize($configuration);
$contacts = ZCRMRestClient::getModule(“Contacts”);
echo "<pre>\n";
print_r($contacts);
echo "\n</pre>";
I've tried \ZCRMRestClient::initialize($configuration) but that hasn't helped.
Solution
I'm going to assume you've executed the composer require zohocrm/php-sdk command, or potentially added the requirement straight into your project's composer.json by hand.
Make sure you're importing the correct namespace for the library - in this case it seems to be zcrmsdk\crm\setup\restclient\ZCRMRestClient
You should write use zcrmsdk\crm\setup\restclient\ZCRMRestClient; at the top of the file then invoke methods as you currently do.
Alternatively, you can invoke methods as in the following example: \zcrmsdk\crm\setup\restclient\ZCRMRestClient::initialize($configuration);
After that the most likely problem is that your autoload file doesn't contain a reference to your library.
composer dump-autoload should fix that (from the command line.)
And finally perhaps you are not requiring the vendor folder correctly!
Answered By - Abulafia
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.