PHPackages                             knik/sugar7wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. knik/sugar7wrapper

ActiveLibrary[API Development](/categories/api)

knik/sugar7wrapper
==================

SugarCRM 7 REST API Wrapper

029PHP

Since Oct 3Pushed 9y agoCompare

[ Source](https://github.com/et-nik/sugarcrm7-api-wrapper-class)[ Packagist](https://packagist.org/packages/knik/sugar7wrapper)[ RSS](/packages/knik-sugar7wrapper/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

SugarCRM REST Client For SugarCRM 7
===================================

[](#sugarcrm-rest-client-for-sugarcrm-7)

License: MIT

Contents
--------

[](#contents)

1. About
2. Installation
3. Usage Example
4. Custom &amp; Undefined Endpoints
5. Troubleshooting
6. About

---

- PHP library interacting with a SugarCRM 7 REST API
- Designed to work with SugarCRM 7 and the v10 REST API

2. Installation via Composer

---

Edit composer.json

```
{
	"require": {
		"spinegar/sugar7wrapper": "dev-master"
	},
	"minimum-stability": "dev"
}
```

Then install with composer

```
$ composer install
```

3.Usage Examples
----------------

[](#3usage-examples)

```
/* Instantiate and authenticate */
$sugar = new \Spinegar\Sugar7Wrapper\Rest();

$sugar->setUrl('https://sugar/rest/v10/')
	->setUsername('restUser')
	->setPassword('password')
	->connect();

/* Instantiate and authenticate for a specific platform*/
$sugar->setUrl('https://sugar/rest/v10/')
    ->setUsername('restUser')
    ->setPassword('password')
    ->setPlatform('mobile')
    ->connect();

/* Retrieve all records in the Cases module */
$sugar->search('Cases');

/* Retrieve all records in the Cases module where the name = 'Case1 Name' or 'Case2 Name' */
$sugar->search('Cases', array(
	'q' => '"Case1 Name" "Case2 Name"'
));

/* Retrieve the name field for all records in the Cases module */
$sugar->search('Cases', array(
	'fields' => 'name'
));

/* Retrieve all records with filter params in the Contacts module */
$sugar->filter('Contacts', array(
    'filter' => array(
        array('first_name' => 'First Name'),
    )
));

/* Count all records with filter params in the Cases module */
$sugar->countRecords('Cases', array(
    'filter' => array(
        array('status' => 'New'),
    )
));

/* Retrieve a specific record from the Cases module */
$sugar->retrieve('Cases', $record_id);

/* Create a case */
$sugar->create('Cases', array(
	'name' => 'Case Name',
	'status' => 'Assigned'
));

/* Update a case */
$sugar->update('Cases', $record_id, array(
    	'status' => 'Closed'
));

/* Favorite a case */
$sugar->favorite('Cases', $record_id);

/* Unfavorite a case */
$sugar->unfavorite('Cases', $record_id);

/* Retrieve cases related to an account */
$sugar->related('Accounts', $record_id, 'cases');

/* Relate a case to an account */
$sugar->relate('Accounts', $record_id, 'cases', $related_record_id);

/*Relate a contact to an opportunity and set relationship data */
$sugar->relate('Opportunities', $record_id, 'contacts', $related_record_id, array(
	'contact_role' => 'Influencer'
));

/* Delete relationship between an account and case */
$sugar->unrelate('Accounts', $record_id, 'cases', $related_record_id);

/* Update relationship data */
$sugar->updateRelationship('Opportunities', $record_id, 'contacts', $related_record_id, array(
	'contact_role' => 'Influencer'
));

/* Retrieve a list of attachments for a case */
$attachments = $sugar->related('Cases', $record_id, 'notes');

foreach($attachments['records'] as $attachment)
{
	$output[] = $sugar->files('Notes', $attachment['id']);
}

return $output;

/* Delete the file associated to the filename field of a note */
$sugar->deleteFile('Notes', $record_id, 'filename');

/* Download  the file associated to the filename field of a note to the server */
$sugar->download('Notes', $record_id, 'filename', '/path/to/destination.ext');

/* Upload a file associated to the filename field of a note to the server */
$sugar->upload('Notes', $record_id, 'filename', '/path/of/local/file.ext');

/* Sending multiple requests */
$results = $this->client->send(function($client){
	return [
		$client->countRecords('Cases'),
		$client->countRecords('Cases'),
		$client->countRecords('Cases'),
	];
});
```

4. Custom &amp; Undefined Endpoints

---

Call custom or undefined endpoints using the following methods.

```
/* Get Endpoint*/
$parameters = array();
$sugar->getEndpoint('MyCustomEndpoint', $parameters);

/* Post Endpoint*/
$parameters = array();
$sugar->postEndpoint('MyCustomEndpoint', $parameters);

/* Put Endpoint*/
$parameters = array();
$sugar->putEndpoint('MyCustomEndpoint', $parameters);

/* Delete Endpoint*/
$parameters = array();
$sugar->deleteEndpoint('MyCustomEndpoint', $parameters);
```

5. Troubleshooting

---

If you are having trouble connecting to a secured site (https), try the following:

```
$sugar = new \Spinegar\Sugar7Wrapper\Rest();
$sugar->setClientOption('verify', false); // This is the important part
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1330709?v=4)[knik](/maintainers/knik)[@knik](https://github.com/knik)

---

Top Contributors

[![spinegar](https://avatars.githubusercontent.com/u/2236579?v=4)](https://github.com/spinegar "spinegar (47 commits)")[![spenserhale](https://avatars.githubusercontent.com/u/5643366?v=4)](https://github.com/spenserhale "spenserhale (5 commits)")[![cmourizard](https://avatars.githubusercontent.com/u/295190?v=4)](https://github.com/cmourizard "cmourizard (4 commits)")[![startupz](https://avatars.githubusercontent.com/u/310652?v=4)](https://github.com/startupz "startupz (4 commits)")[![bountin](https://avatars.githubusercontent.com/u/208063?v=4)](https://github.com/bountin "bountin (2 commits)")[![jlyons-bgl](https://avatars.githubusercontent.com/u/25048418?v=4)](https://github.com/jlyons-bgl "jlyons-bgl (2 commits)")[![nickescobedo](https://avatars.githubusercontent.com/u/2837169?v=4)](https://github.com/nickescobedo "nickescobedo (2 commits)")[![esimonetti](https://avatars.githubusercontent.com/u/1671865?v=4)](https://github.com/esimonetti "esimonetti (2 commits)")[![et-nik](https://avatars.githubusercontent.com/u/3670640?v=4)](https://github.com/et-nik "et-nik (2 commits)")[![thomasez](https://avatars.githubusercontent.com/u/683490?v=4)](https://github.com/thomasez "thomasez (1 commits)")[![cmoore4](https://avatars.githubusercontent.com/u/311193?v=4)](https://github.com/cmoore4 "cmoore4 (1 commits)")[![denheck](https://avatars.githubusercontent.com/u/235116?v=4)](https://github.com/denheck "denheck (1 commits)")[![huhwatnou](https://avatars.githubusercontent.com/u/4171421?v=4)](https://github.com/huhwatnou "huhwatnou (1 commits)")[![mattstauffer](https://avatars.githubusercontent.com/u/151829?v=4)](https://github.com/mattstauffer "mattstauffer (1 commits)")[![askhogan](https://avatars.githubusercontent.com/u/635449?v=4)](https://github.com/askhogan "askhogan (1 commits)")

### Embed Badge

![Health badge](/badges/knik-sugar7wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/knik-sugar7wrapper/health.svg)](https://phpackages.com/packages/knik-sugar7wrapper)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
