PHPackages                             betalabs/engine-phpsdk - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. betalabs/engine-phpsdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

betalabs/engine-phpsdk
======================

SDK for Engine

v2.0.8(1y ago)111.0k↓46.7%[1 PRs](https://github.com/Betalabs/engine-phpsdk/pulls)2PHPPHP ^8.0

Since Sep 29Pushed 10mo ago8 watchersCompare

[ Source](https://github.com/Betalabs/engine-phpsdk)[ Packagist](https://packagist.org/packages/betalabs/engine-phpsdk)[ RSS](/packages/betalabs-engine-phpsdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (36)Used By (2)

Engine-PhpSDK
=============

[](#engine-phpsdk)

[![Buddy Status](https://camo.githubusercontent.com/12ee16b8fbf259fff4c912a4f2ecf2fbf0fabde6890f1c6789138e876d00bcea/68747470733a2f2f6170702e62756464792e776f726b732f626574616c6162732f656e67696e652d70687073646b2f706970656c696e65732f706970656c696e652f35393736342f62616467652e7376673f746f6b656e3d37363934613431383637613439346435626535646436316136373566376534336663313863303533616239633630393161333932636531313163643033646535)](https://camo.githubusercontent.com/12ee16b8fbf259fff4c912a4f2ecf2fbf0fabde6890f1c6789138e876d00bcea/68747470733a2f2f6170702e62756464792e776f726b732f626574616c6162732f656e67696e652d70687073646b2f706970656c696e65732f706970656c696e652f35393736342f62616467652e7376673f746f6b656e3d37363934613431383637613439346435626535646436316136373566376534336663313863303533616239633630393161333932636531313163643033646535)

This package is a helper to integrate with Engine. The documentation for integration can be found [here](https://betalabs.atlassian.net/wiki/spaces/APPS/overview).

Request
-------

[](#request)

The `Betalabs\Engine\Request` class is responsible for initializing the request specific types objects. If you need to make a GET request call you can:

```
$get = \Betalabs\Engine\Request::get();
$response = $get->send('path/to/api'); // ['data' => [...]]
$statusCode = $get->statusCode(); // 200
```

It's also possible to inject the `Betalabs\Engine\Request`:

```
class Object {

  protected $request;

  public __construct(\Betalabs\Engine\Request $request)
  {
    $this->request = $request;
  }

  public function get()
  {
    $get = $this->request->get();
    $response = $get->send('path/to/api'); // ['data' => [...]]
    $statusCode = $get->statusCode(); // 200
  }

}
```

There are five methods possible: GET, POST, PUT, PATCH and DELETE. In all methods the first parameter is the API path. For POST, PUT, PATCH and DELETE the second parameter is the data to be sent to the API, it must be sent in an array. For instance:

```
$post = \Betalabs\Engine\Request::post();
$post->send(
  'path/to/api',
  [
    'parameter1' => 'value 1',
    'parameter2' => 'value 2',
    // ...
  ]
);
```

### URL builder

[](#url-builder)

By default the package always adds the `api` prefix to all URLs. In the previous example the URL will be (assuming `http://engine.url` is the endpoint): `http://engine.url/api/path/to/api`.

It is possible to change this behavior adding using `setEndpointSuffix()` method which accepts a `string` or `null`:

```
$get->setEndpointSuffix(null)->send('path/to/api'); // http://engine.url/path/to/api
```

Configuration file
------------------

[](#configuration-file)

Configuration file is expected to be stored in the main (root) directory of the project and shall be named `engine-sdk.xml`.

This is its basic format:

```

```

Each section of this document will relate to its configuration.

Routes
------

[](#routes)

All routes must be declared in one single file which implements `Betalabs\Engine\RouteProvider` interface. The `route` method receives a `Aura\Router\Map` parameter, its usage can be checked [here](https://github.com/auraphp/Aura.Router/blob/3.x/docs/defining-routes.md).

The location of route file is declared in configuration file:

```

```

Where `path` is the relative path to the file (based on the root directory) and `class` is the class name (with namespace if exists). The `path` is not required when the class is autoloaded.

### Engine requests

[](#engine-requests)

All requests to the App are dispatched by the Engine, these requests might be originated by an trigger or an authenticated user. However, for some applications, it might be useful to own some endpoints for loose requests (that are not directly dispatched by Engine).

Assume we are building an app that creates a tag for an order named *TagCreator*; there are two main starters: (1) An Engine user is managing the orders and click in "Make tag"; (2) An external system wants to generate a tag.

In the first case Engine owns a trigger to dispatch an request to the app. In this request Engine will add some information to identify which order the user wants to generate the tag (such as the ID) and via Engine requests is possible to gather all information to response the request with the tag. The second case the app must own a route prepared to receive all information via request parameter and then generate the tag.

Note in the second case Engine does not take any action and is not used to generate any data. To make a request directly to the app dispatch to: `http://{app-company}-{app-repository}.engine.url/` where `{app-company}` and `{app-repository}` are GitHub's Company and Repository name (used to register app in Engine).

Authentication
--------------

[](#authentication)

By default all requests are authenticated using stored token. It is possible to disable using `mustNotAuthorize` method:

```
 $get = \Betalabs\Engine\Request::get();
 $response = $get
  ->mustNotAuthorize()
  ->send('path/to/api');
```

Of course is possible to enable using the `mustAuthorize()` method.

Permissions
-----------

[](#permissions)

During the App boot process Engine asks for the permissions. There is an easy way to define them where you must create a class that implements `Betalabs\Engine\PermissionProvider`. This class must own a method that adds all permissions:

```
public function permissions(\Betalabs\Engine\Permissions\Register $register)
{

    $register->add(new \Betalabs\Engine\Permissions\Permission(
        'permission-0-name',
        'Permission #0 name',
        'Permission #0 description'
    ));

    $register->add(new \Betalabs\Engine\Permissions\Permission(
        'permission-1-name',
        'Permission #1 name',
        'Permission #1 description'
    ));

}
```

The location of this file is declared in configuration file:

```

```

Where `path` is the relative path to the file (based on the root directory) and `class` is the class name (with namespace if exists). The `path` is not required when the class is autoloaded.

If this node does not exist or no permission is declared then an 404 HTTP code is returned to Engine when it asks for the permission.

By default the `boot/permission` route is automatically defined and treated by the SDK.

Database migration
------------------

[](#database-migration)

During the App boot process Engine starts migration process. You can create a class that implements `Betalabs\Engine\MigrationProvider`. This class must own a method that runs the migration:

```
public function run()
{

    // Migration process

    return new \Betalabs\Engine\Requests\BootResponse(
        true,
        'Success!'
    );

}
```

It is necessary to return an `Betalabs\Engine\Requests\BootResponse` object, this way Engine will be able to log what happen during this process.

The location of this file is declared in configuration file:

```

```

Where `path` is the relative path to the file (based on the root directory) and `class` is the class name (with namespace if exists). The `path` is not required when the class is autoloaded.

If this node does not exist then SDK informs Engine no migration process is needed.

By default the `boot/database` route is automatically defined and treated by the SDK.

Genesis boot
------------

[](#genesis-boot)

During process of associate an App with a tenant Engine boot Genesis process. You can create a class that implements `Betalabs\Engine\GenesisProvider`. This class must own a method that runs the migration:

```
public function run()
{

    // Genesis process

    return new \Betalabs\Engine\Requests\BootResponse(
        true,
        'Success!'
    );

}
```

It is necessary to return an `Betalabs\Engine\Requests\BootResponse` object, this way Engine will be able to log what happen during this process.

The location of this file is declared in configuration file:

```

```

Where `path` is the relative path to the file (based on the root directory) and `class` is the class name (with namespace if exists). The `path` is not required when the class is autoloaded.

If this node does not exist then SDK informs Engine no genesis process is needed.

By default the `boot/genesis` route is automatically defined and treated by the SDK.

Development
-----------

[](#development)

During development you might want to manually define tokens and endpoints. It is possible using configuration file.

### Endpoint

[](#endpoint)

By default all requests are dispatched against production URL however you can change this behavior using `environment` section in configuration file.

```

```

`env` node can be filled with two values: `Sandbox` or `Production`; this way the endpoint URL will be automatically defined. Nevertheless if you fill `endpoint` node this value will be used as endpoint URL independently `env` node value.

`environment`, `env` and `endpoint` nodes are not required.

### Token

[](#token)

You might want to use a specific token to access Engine API. This can be done through `auth` section in configuration file:

```

```

- `accessToken` is the access token string to be used in all requests

The `auth` node is not required, however to be used `accessToken` subnode, it must be declared.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance48

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88% 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.

###  Release Activity

Cadence

Every ~88 days

Recently: every ~104 days

Total

31

Last Release

490d ago

Major Versions

v0.8.0 → v1.02020-09-30

v1.3 → v2.0.02023-04-28

PHP version history (4 changes)v0.1PHP ^7.1

v1.0PHP ^7.2.5

v1.2PHP ^7.3

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5718a3a2c41de555560fde3279aaf122ce1584540c5f123e7661eaa3d79dba73?d=identicon)[diego-betalabs](/maintainers/diego-betalabs)

---

Top Contributors

[![diego-betalabs](https://avatars.githubusercontent.com/u/1482834?v=4)](https://github.com/diego-betalabs "diego-betalabs (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![marcelobetalabs](https://avatars.githubusercontent.com/u/2293700?v=4)](https://github.com/marcelobetalabs "marcelobetalabs (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/betalabs-engine-phpsdk/health.svg)

```
[![Health](https://phpackages.com/badges/betalabs-engine-phpsdk/health.svg)](https://phpackages.com/packages/betalabs-engine-phpsdk)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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