This package contains code to help you copy ZohoCRM records directly into your database.
This project is a set of tools to help you copy your Zoho CRM records directly into your database. The tool will create new tables in your database matching Zoho records. If you are looking to synchronize data from ZohoCRM with your own tables, you should rather have a look at ZohoCRM Sync. It is built on top of the ZohoCRM ORM. Before reading further you should get used to working with ZohoCRM ORM, so if you do not know this library, STOP READING NOW and follow this link.
This projects provides a
ZohoDatabaseCopier class, with a simple
fetchFromZoho method. This method takes a
ZohoDao in argument.
ZohoDaos can be created using the ZohoCRM ORM.
It also provides a
ZohoDatabasePusher class with a
pushToZoho method to push data to Zoho CRM.
// $connection is a Doctrine DBAL connection to your database. $databaseCopier = new ZohoDatabaseCopier($connection); // $contactZohoDao is the Zoho Dao to the module you want to copy. $databaseCopier->fetchFromZoho($contactZohoDao);
The copy command will create a 'zoho_Contacts' table in your database and copy all data from Zoho. Table names are prefixed by 'zoho_'.
You can change the prefix using the second (optional) argument of the constructor:
// Generated database table will be prefixed with "my_prefix_" $databaseCopier = new ZohoDatabaseCopier($connection, "my_prefix_");
By default, copy is performed incrementally. If you have touched some of the data in your database and want to copy again
everything, you can use the second parameter of the
// Pass false as second parameter to force copying everything rather than doing an incremental copy. $databaseCopier->fetchFromZoho($contactZohoDao, false);
With the same
$databaseCopier you can fetch the users from zoho.
// $connection is a Doctrine DBAL connection to your database. $databaseCopier = new ZohoDatabaseCopier($connection); ```php // $userResponse is the Zoho Client Response from zoho-crm-orm package. $databaseCopier->fetchUserFromZoho($userResponse);
// $connection is a Doctrine DBAL connection to your database. $databaseSync = new ZohoDatabasePusher($connection); // $contactZohoDao is the Zoho Dao to the module you want to push. $databaseSync->pushToZoho($contactZohoDao);
This project requires MySQL 5.7+ to work.
The project also comes with a Symfony Command that you can use to easily copy tables.
The command's constructor takes in parameter a
ZohoDatabaseCopier instance, a
ZohoDatabasePusher instance and a
ZohoClient. This command
regenerates automatically the Daos in order to pass them in
ZohoDatabaseCopier instance, a
# Command to synchronize data (both ways) $ console zoho:sync # Command to only fetch data from Zoho $ console zoho:sync --fetch-only # Command to only push data to Zoho $ console zoho:sync --push-only
ZohoDatabaseCopier, you can register one or many listeners. These listeners should implement the
You register those listener by passing an array of listeners to the 3rd parameter of the constructor:
$listener = new MyListener(); $databaseCopier = new ZohoDatabaseCopier($connection, "my_prefix_", [ $listener ]);