dynamics-tools / dynamics-web-api-php-wrapper
PHP 8.1 wrapper for Microsoft Dynamics Web API
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.3
This package is auto-updated.
Last update: 2025-04-17 22:10:00 UTC
README
Introduction
This package is not intended to be an in-depth SDK for Microsoft Dynamics. Its main purpose is to simplify the process of authentication and request setup for users of Dynamics Web API.
Authentication
We utilize server-to-server OAuth authentication via an application user. To successfully authenticate, you'll need to set the following environment variables:
APPLICATION_ID: Application (Client) ID
APPLICATION_SECRET: Application (Client) Secret
TENANT_ID: Tenant ID
INSTANCE_URL: Dynamics (Instance) URL
API Documentation
The API documentation for this version of the Dynamics Web API can be found here.
Usage Example
Ensure the environment variables are set before running the example.
Using the Client
use DynamicsWebApi\Client; use DynamicsWebApi\ClientFactory; require_once 'vendor/autoload.php'; $client = Client::createInstance(); $response = $client->request('/CloneAsSolution', 'POST', [ 'ParentSolutionUniqueName' => 'MySolution', 'DisplayName' => 'MySolution', 'VersionNumber' => '1.12.0.0' ]); $responseJson = json_decode($response->getBody()->getContents(), true); echo $responseJson['SolutionId'];
Using the Helper
use DynamicsWebApi\Helper; require_once 'vendor/autoload.php'; $helper = new Helper(); $helper->updateEntity('pluginassemblies', '38938383-383838-392912-192882', ['name' => 'MyPluginAssembly'], '9.2'); $helper->publishAllChanges();