Skip to content
Mike Russell edited this page Oct 5, 2017 · 15 revisions

SugarCRM REST PHP Client

Versions

There are 2 Versions of the REST Client (v1 & v2), that differ in their namespaces and usage. This Wiki is mainly geared toward the latest version (v2.x) of the REST Client, however we do provide the legacy REST Client v1 Wiki here.

Please review the V1 vs V2 Guide to better understand the differences between the versions, as v2 offers significantly more and different functionality.

Architecture

There are three main components to the PHP REST Client, and a fourth optional component.

  • Client
    • The main object which acts as a Logical container to interact with all components, and make them work to fit with an API flow.
  • Endpoint
    • The Endpoint component contains 3 core constructs
      1. EndpointProvider - A factory like object that houses the registration of Endpoints and their associated properties
      2. Endpoints - The actual Endpoint objects that house the logic in regards to an API Endpoint.
      3. Data - For certain types of Endpoints, it was beneficial to have a data construct that was smarter than a typical Array or StdObject. It allows for interaction as an Array or an Object, and allows for more complex logic like data validation or even query building.
  • Auth
    • The AuthController contains
  • Storage
    • This can be optionally used with an AuthController. The Sugar Client that comes out of the box, uses a Static Storage (i.e. in memory) so that Authentication Tokens are not lost between Client Objects.

These four areas are designated by the folder structure in the src/ directory of the repository.

Sugar7Api Client

The Sugar REST PHP Client lays out a framework for easily working with the Sugar 7 REST API. It also includes a default Client that can be quickly accessed to connect to any sugar app instance. Review the Sugar7Api Client documentation for usage of that Client to get your development started.

Contributing

Version 2.x is being maintained and actively developed with. In order for the Sugar REST PHP Client to work well for all, version 2.x will not change in the overarching usage of architecture and the usage of the Sugar Client. That being said, if a Bug is found when using the Sugar REST PHP Client please submit an issue, and if you have a solution, submit a Pull Request for that issue. We will try to resolve Bugs as quickly as possible, and release a new version with those Bug fixes.

As far as adding functionality goes, if you would like other Endpoints that are not already included in the Sugar REST PHP Client, we would be more than happy to add those in for version 2.x. What we will try not do with version 2.x, is alter the current usages of Endpoints, as we want to maintain backwards compatibility with any code that may be using the framework, however it is best to review the release notes of a published version to see if there are major changes to usage. You can submit an feature requests via the Github Issues page as well.

Lastly, if you see any documentation that is incorrect in the Wiki, please submit an issue. Unfortunately the Wiki is not open to public editing, however if you submit an issue, and you are proposing a change to the documentation, you can do the following:

  1. Pull the wiki down via Git
  2. Sync to your own fork
  3. Make your changes to the documentation
  4. Include a link to your Fork's updated Wiki page in the issue