inetprocess / libsugarcrm
This library provides a various classes to interact with SugarCRM
Installs: 9 068
Dependents: 3
Suggesters: 0
Security: 0
Stars: 8
Watchers: 10
Forks: 5
Open Issues: 2
Requires
- php: >=5.3
- psr/log: ~1.0
- symfony/filesystem: ~2
- symfony/finder: ~2
- symfony/process: ^2.8
- symfony/yaml: ~2
Requires (Dev)
- phpunit/dbunit: ~1.3
- phpunit/phpunit: ~4.0
- dev-master
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.22-beta
- 1.1.21-beta
- 1.1.20-beta
- 1.1.19-beta
- 1.1.18-beta
- 1.1.17-beta
- 1.1.16-beta
- 1.1.15-beta
- 1.1.14-beta
- 1.1.13-beta
- 1.1.12-beta
- 1.1.11-beta
- 1.1.10-beta
- 1.1.9-beta
- 1.1.8-beta
- 1.1.7-beta
- 1.1.6-beta
- 1.1.5-beta
- 1.1.4-beta
- 1.1.3-beta
- 1.1.2-beta
- 1.1.1-beta
- 1.1.0-beta
- 1.0.0-beta
- 0.9.1
- 0.9
- dev-mon_14054
- dev-langfilecleaner
- dev-wip_rsauvatinet
- dev-code_cleaning
- dev-sugarcli_integration
This package is not auto-updated.
Last update: 2024-12-21 19:31:57 UTC
README
That library allows anybody to interact with a SugarCRM application, outside that application. Suppose you need to do a importation script, running every night, with a very specific set of transformations or check. Then you need that kind of tools to be able to "Login" to SugarCRM, create or update beans, do SQL queries, etc ...
Warning
- Be very careful that Sugar doesn't do a very "clean" job so it's better to deactivate the strict standards erorr reporting in PHP to be able to use it. When I launch my script, I usualy do something like:
php -d 'error_reporting=E_ALL & ~E_STRICT' test.php
-
If you are not using my classes in another class (if you do like in examples below, directly calling the library), be more careful: don't name your variables like sugar does, else you'll overwrite it (example: $db or $log).
-
Last but not the least: you'll be able to instanciate the EntryPoint for only one instance of Sugar ! It uses GLOBALS variable such as $GLOBALS['db'] and I let you imagine what will happen if it's overwritten by another Instance of SugarCRM ;)
Classes
Inet\SugarCRM\Application
Gives general information about SugarCRM Installation. Others classes depends on this one.
Usage Example:
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\Application; $sugarApp = new Application(new NullLogger(), '/home/sugarcrm/www'); echo $sugarApp->getPath(); if ($sugarApp->isValid()) { echo $sugarApp->getVersion(); }
Inet\SugarCRM\EntryPoint
It says where is Sugar and does the basic steps to "login" into SugarCRM. EntryPoint needs a logger because other classes log a lot of stuff. The EntryPoint can only be loaded once for the entire program.
Usage Example:
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\Application; use Inet\SugarCRM\EntryPoint; if (!EntryPoint::isCreated()) { $nullLogger = new NullLogger; $sugarApp = new Application($nullLogger, '/home/sugarcrm/www'); // enter sugar EntryPoint::createInstance($sugarApp, '1'); } $sugarEP = EntryPoint::getInstance();
Inet\SugarCRM\Bean
Most complete class to :
- Get a list of available modules (getBeansList())
- Get an Bean (getBean())
- Create a Bean (newBean())
- Get a list of records for a module (getList())
- ...
Usage Example:
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\Bean; if (!EntryPoint::isCreated()) { $nullLogger = new NullLogger; $sugarApp = new Application($nullLogger, '/home/sugarcrm/www'); // enter sugar EntryPoint::createInstance($sugarApp, '1'); } $sugarEP = EntryPoint::getInstance(); // instanciate the Bean class to retrieve User with id 1 $inetSugarBean = new Bean($sugarEP); $adminUser = $inetSugarBean->getBean('Users', 1); echo $adminUser->name;
Inet\SugarCRM\BeanFactoryCache
Don't use it directly, it's directly used by Inet\SugarCRM\Bean to clean the cache during long loops.
Inet\SugarCRM\DB
Useful to query SugarCRM DB directly.
Usage Example:
<?php require_once 'vendor/autoload.php'; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\DB; // get the DB Class $inetSugarDB = new DB(EntryPoint::getInstance()); $users = $inetSugarDB->query('SELECT * FROM users'); echo count($users);
Inet\SugarCRM\Utils
Various Utils to create labels, dropdown, encode or decode multiselect, etc...
Usage Example:
<?php require_once 'vendor/autoload.php'; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\Utils; // get the Utils Class $inetSugarUtils = new Utils(EntryPoint::getInstance()); // Convert an array to a multiselect $convertedArray = $inetSugarUtils->arrayToMultiselect(array('test' => 'inet')); echo $convertedArray;
Inet\SugarCRM\SugarQueryIterator
Iterator class to iterate in a memory safe way SugarQuery results.
Usage Example: Loop records 100 to 300
<?php $query = new \SugarQuery(); // setup $query $iter = new SugarQueryIterator($query); $iter->setStartOffset(100); foreach ($iter as $id => $bean) { // Do something with $bean if ($iter->getIterationCounter() >= 200) { break; } }