ziack / zoho-crm-orm
此包的最新版本(1.6)没有可用的许可证信息。
一个用于通过API操作Zoho CRM账户数据的ORM包。
1.6
2020-05-15 21:53 UTC
Requires
- php: >=5.5
- gossi/php-code-generator: ^0.4 || ^0.5
- guzzlehttp/guzzle: ~6.0
- psr/log: ~1.0
- wabel/zoho-crm-client-wrapper: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~1.0
README
Wabel的Zoho-CRM ORM
高度借鉴自mctekk的工作
这是什么?
此项目是一个PHP连接器,用于连接Zoho CRM。使用此连接器从您的PHP应用程序访问ZohoCRM数据。
它与其他连接器有何不同?
与其他Zoho CRM客户端不同,Zoho-CRM ORM使用一个代码生成器来生成Beans和DAO,以便从PHP轻松访问Zoho对象。
Beans和DAO是什么?
代码胜过长篇大论,以下是一个示例
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(); }
你必须始终记住
- Beans用于映射Zoho中的记录。每个Zoho模块都有一个类
- DAOs用于将Beans发送到Zoho。每个Zoho模块都有一个DAO
但我如何生成Beans和DAOs?
有多种技术。
使用纯PHP代码
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'; // That returns an array containing each created Dao by using the fully qualified class name $generator->generateAll($directory, $namespace);
设置单元测试
感兴趣于贡献?您可以轻松设置单元测试环境
- 将
phpunit.xml.dist
文件复制到phpunit.xml
- 更改存储的
auth_token
- 运行测试:
vendor/bin/phpunit
故障排除
- 我正在保存一个bean(使用DAO的
save
方法)并在之后搜索它(使用searchRecords
)。bean没有返回。
这是Zoho的问题。Zoho大约需要一分钟来索引您插入的记录。因此,您必须等待大约一分钟,Zoho bean才能使用searchRecords
方法找到。