PHPackages                             bringo247/asakusuma-sugarcrm-wrapper - 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. bringo247/asakusuma-sugarcrm-wrapper

ActiveLibrary

bringo247/asakusuma-sugarcrm-wrapper
====================================

SugarCRM REST API Wrapper Class

01.4k2PHP

Since Nov 25Pushed 10y ago1 watchersCompare

[ Source](https://github.com/bringo247/SugarCRM-REST-API-Wrapper-Class)[ Packagist](https://packagist.org/packages/bringo247/asakusuma-sugarcrm-wrapper)[ RSS](/packages/bringo247-asakusuma-sugarcrm-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SugarCRM REST API Wrapper Class
===============================

[](#sugarcrm-rest-api-wrapper-class)

by Asa Kusuma

License: MIT

Contents
--------

[](#contents)

1. About
2. Installation
3. Usage Example
4. Notes
5. get\_note\_attachment() Example
6. set\_note\_attachment() Example

1.About
-------

[](#1about)

- PHP wrapper class for interacting with a SugarCRM REST API
- Creating, reading, and updating capability
- More info on SugarCRM:
- API docs:
- Designed to work with SugarCRM v.6

2. Installation via Composer

---

Edit composer.json

```
{
	"require": {
		"asakusuma/sugarcrm-wrapper": "dev-master"
	},
	"minimum-stability": "dev"
}

```

Then install with composer

```
$ composer install

```

3.Usage Example
---------------

[](#3usage-example)

```
$sugar = new \Asakusuma\SugarWrapper\Rest;

$sugar->setUrl('https://sugarcrm/service/v2/rest.php');
$sugar->setUsername('user');
$sugar->setPassword('password');

$sugar->connect();

$results = $sugar->get("Accounts",array('id','name'));

print_r($results);

```

See example.php for another example.

4.Notes
-------

[](#4notes)

- The `is_valid_id()` function may need to modify for different versions of SugarCRM.
- Different versions of SugarCRM have different ID formats.

5.get\_note\_attachment() Example
---------------------------------

[](#5get_note_attachment-example)

> This example outputs the contents of a note's attachment, given the note ID. Assumes $note\_id contains the ID of the note you wish to modify.

```
$sugar = new \Asakusuma\SugarWrapper\Rest;

$sugar->setUrl('https://sugarcrm/service/v2/rest.php');
$sugar->setUsername('user');
$sugar->setPassword('password');

$sugar->connect();

$result = $sugar->get_note_attachment($note_id);
$filename = $result['note_attachment']['filename'];
$file = $result['note_attachment']['file'];

$file = base64_decode($file);
header("Cache-Control: no-cache private");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.$filename);
header("Content-Type: application/vnd.ms-excel");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. strlen($file));
echo $file;
exit;

```

6.set\_note\_attachment() Example
---------------------------------

[](#6set_note_attachment-example)

> This example illustrates how to set a note's attachment from an html form. Assumes $note\_id contains the ID of the note you wish to modify.

### HTML Code

[](#html-code)

```

```

### PHP Code (example.php)

[](#php-code-examplephp)

```
$sugar = new \Asakusuma\SugarWrapper\Rest;

$sugar->setUrl('https://sugarcrm/service/v2/rest.php');
$sugar->setUsername('user');
$sugar->setPassword('password');

$sugar->connect();

if ($_FILES["note_file"]["error"] > 0) {
	// Error: $_FILES["file"]["error"]
} else if(isset($_FILES['note_file']['tmp_name']) && $_FILES['note_file']['tmp_name']!="") {
	$handle = fopen($_FILES['note_file']['tmp_name'], "rb");
	$filename = $_FILES['note_file']['name'];
	$contents = fread($handle, filesize($_FILES['note_file']['tmp_name']));
	$binary = base64_encode($contents);
	$file_results = $sugar->set_note_attachment($note_id,$binary,$filename);
}

```

7.get\_available\_modules() Example
-----------------------------------

[](#7get_available_modules-example)

> This example illustrates how to get the available modules in Sugar. All of them. This is a handy function to use when building future proof sugarcrm plugins.

### PHP Code (example.php)

[](#php-code-examplephp-1)

```
$sugar = new \Asakusuma\SugarWrapper\Rest;
$modules = $sugar->get_available_modules();

```

> BAM! Now loop through the array that was returned and stored in $modules. You could use this to display a dropdown in the admin panel that displays all modules a user would want to connect your sugarcrm plugin to.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.9% 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://www.gravatar.com/avatar/835eddf535b782158fa2ff6f7aca1a4b5249ebb332015735ff084711c44dd89a?d=identicon)[bringo247](/maintainers/bringo247)

---

Top Contributors

[![asakusuma](https://avatars.githubusercontent.com/u/597574?v=4)](https://github.com/asakusuma "asakusuma (37 commits)")[![spinegar](https://avatars.githubusercontent.com/u/2236579?v=4)](https://github.com/spinegar "spinegar (14 commits)")[![Kostanos](https://avatars.githubusercontent.com/u/1136702?v=4)](https://github.com/Kostanos "Kostanos (3 commits)")[![chadhutchins](https://avatars.githubusercontent.com/u/47898?v=4)](https://github.com/chadhutchins "chadhutchins (3 commits)")[![koyhoge](https://avatars.githubusercontent.com/u/49316?v=4)](https://github.com/koyhoge "koyhoge (2 commits)")[![bringo247](https://avatars.githubusercontent.com/u/16018264?v=4)](https://github.com/bringo247 "bringo247 (2 commits)")[![filiptepper](https://avatars.githubusercontent.com/u/3822?v=4)](https://github.com/filiptepper "filiptepper (1 commits)")[![andarnold](https://avatars.githubusercontent.com/u/18539597?v=4)](https://github.com/andarnold "andarnold (1 commits)")[![KyleGawryluk](https://avatars.githubusercontent.com/u/3766614?v=4)](https://github.com/KyleGawryluk "KyleGawryluk (1 commits)")[![mjones517](https://avatars.githubusercontent.com/u/11433552?v=4)](https://github.com/mjones517 "mjones517 (1 commits)")[![samy](https://avatars.githubusercontent.com/u/1282106?v=4)](https://github.com/samy "samy (1 commits)")[![shano](https://avatars.githubusercontent.com/u/167567?v=4)](https://github.com/shano "shano (1 commits)")[![Shotman](https://avatars.githubusercontent.com/u/6579166?v=4)](https://github.com/Shotman "Shotman (1 commits)")[![askhogan](https://avatars.githubusercontent.com/u/635449?v=4)](https://github.com/askhogan "askhogan (1 commits)")[![andreipdev](https://avatars.githubusercontent.com/u/1207190?v=4)](https://github.com/andreipdev "andreipdev (1 commits)")

### Embed Badge

![Health badge](/badges/bringo247-asakusuma-sugarcrm-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/bringo247-asakusuma-sugarcrm-wrapper/health.svg)](https://phpackages.com/packages/bringo247-asakusuma-sugarcrm-wrapper)
```

PHPackages © 2026

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