PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

[FIXED] Class not found error with composer autoload

 February 05, 2022     autoload, composer-php, php, zoho     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing