wabel / zoho-crm-copy-db
This package contains code to help you copy ZohoCRM records directly into your database.
Installs: 11 635
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 6
Open Issues: 2
Requires
- php: >=5.6
- danielstjules/stringy: ~2.2
- doctrine/dbal: ~2.5
- mouf/utils.common.lock: ~1.0
- symfony/console: ~2.0 | ~3.0
- wabel/zoho-crm-orm: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~1.0
This package is auto-updated.
Last update: 2024-11-29 04:30:35 UTC
README
Wabel's Zoho-CRM Database copier
What is this?
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.
How does it work?
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.
ZohoDatabaseCopier for Module
Usage:
// $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 copy
method:
// Pass false as second parameter to force copying everything rather than doing an incremental copy. $databaseCopier->fetchFromZoho($contactZohoDao, false);
ZohoDatabaseCopier for Users
With the same $databaseCopier
you can fetch the users from zoho.
Usage:
// $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);
ZohoDatabasePusher
Usage:
// $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);
Requirements
This project requires MySQL 5.7+ to work.
Symfony command
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, aZohoDatabasePusher
instance and a ZohoClient
. This command
regenerates automatically the Daos in order to pass them in ZohoDatabaseCopier
instance, aZohoDatabasePusher
.
Usage:
# 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
Listeners
For each ZohoDatabaseCopier
, you can register one or many listeners. These listeners should implement the
ZohoChangeListener
interface.
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 ]);