Heavily forked from mctekk's work
This project is a PHP connector to Zoho CRM. Use this connector to access ZohoCRM data from your PHP application.
Unlike other Zoho CRM clients, the Zoho-CRM ORM uses a code generator to generate Beans and DAOs to easily access Zoho objects from PHP.
A small bit of code is better than a long phrase, here you go with a sample:
use \Wabel\Zoho\CRM\ZohoClient;
// The ZohoClient class is the low level class used to access Zoho.
$zohoClient = new ZohoClient($zohoAuthToken);
// Use the "DAO" class to write to some module of Zoho.
// Each module (even custom ones) has its own class.
$contactZohoDao = new ContactZohoDao($zohoClient);
// For each DAO, there is a bean associated.
$contact = new Contact();
$contact->setLastName("Doe");
$contact->setFirstName("John");
// Use the "save" method to save the bean.
$contactDao->save($contact);
// Use the "searchRecords" method to fetch data from Zoho.
$records = $contactDao->searchRecords("(Last Name:FooBar)");
foreach ($records as $record) {
// Each record is a "Contact" object.
echo $record->getLastName();
}
What you must always remember:
- Beans are used to map records in Zoho. There is one class per Zoho module
- DAOs are used to send beans to Zoho. There is one DAO per Zoho module
There are several techniques.
Using pure PHP code:
use \Wabel\Zoho\CRM\ZohoClient;
// The ZohoClient class is the low level class used to access Zoho.
$zohoClient = new ZohoClient($zohoAuthToken);
// The EntitiesGeneratorService class is in charge of generating Beans and DAOs.
$entitiesGenerator = new EntitiesGeneratorService($client);
// The target directory we will write into.
$directory = __DIR__.'/src/TestNamespace/';
// The namespace for the beans and DAOs.
$namespace = 'TestNamespace';
$generator->generateAll($directory, $namespace);
Interested in contributing? You can easily set up the unit tests environment:
- copy the
phpunit.xml.dist
file intophpunit.xml
- change the stored
auth_token
- run the tests:
vendor/bin/phpunit
- I'm saving a bean (using the
save
method of the DAO) and searching for it afterwards (usingsearchRecords
). The bean is not returned.
This is a Zoho issue. Zoho takes about one minute to index the records you insert. So you must wait about one minute before the Zoho bean you saved will be findable using thesearchRecords
method.