{"id":13527820,"url":"https://github.com/immobiliare/braze-php-sdk","last_synced_at":"2025-07-11T22:09:33.457Z","repository":{"id":42627467,"uuid":"447246907","full_name":"immobiliare/braze-php-sdk","owner":"immobiliare","description":"A PHP client to interact with Braze API","archived":false,"fork":false,"pushed_at":"2025-03-17T14:29:20.000Z","size":174,"stargazers_count":21,"open_issues_count":0,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-20T12:07:53.172Z","etag":null,"topics":["api-client","braze","braze-api","braze-sdk","client","client-library","hacktoberfest","php","sdk","sdk-php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/immobiliare.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-12T14:21:39.000Z","updated_at":"2025-03-17T14:24:25.000Z","dependencies_parsed_at":"2024-01-17T09:36:41.368Z","dependency_job_id":"c5afb584-7f00-4403-ba32-76e2803a465a","html_url":"https://github.com/immobiliare/braze-php-sdk","commit_stats":{"total_commits":33,"total_committers":4,"mean_commits":8.25,"dds":0.2727272727272727,"last_synced_commit":"1e68ea67ebff883ba7809ed0525556368cf34b6d"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/immobiliare/braze-php-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/immobiliare%2Fbraze-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/immobiliare%2Fbraze-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/immobiliare%2Fbraze-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/immobiliare%2Fbraze-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/immobiliare","download_url":"https://codeload.github.com/immobiliare/braze-php-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/immobiliare%2Fbraze-php-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262072194,"owners_count":23254303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","braze","braze-api","braze-sdk","client","client-library","hacktoberfest","php","sdk","sdk-php"],"created_at":"2024-08-01T06:02:02.835Z","updated_at":"2025-07-11T22:09:33.387Z","avatar_url":"https://github.com/immobiliare.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"Braze PHP SDK\n============\n\n![CI](https://github.com/immobiliare/braze-php-sdk/workflows/CI/badge.svg) \n[![codecov](https://codecov.io/gh/immobiliare/braze-php-sdk/branch/main/graph/badge.svg?token=8H5dESJuiq)](https://codecov.io/gh/immobiliare/braze-php-sdk) \n[![Latest Stable Version](https://poser.pugx.org/immobiliarelabs/braze-sdk/v)](https://packagist.org/packages/immobiliarelabs/braze-sdk) \n[![Total Downloads](https://poser.pugx.org/immobiliarelabs/braze-sdk/downloads)](https://packagist.org/packages/immobiliarelabs/braze-sdk) \n[![Latest Unstable Version](https://poser.pugx.org/immobiliarelabs/braze-sdk/v/unstable)](https://packagist.org/packages/immobiliarelabs/braze-sdk) \n[![License](https://poser.pugx.org/immobiliarelabs/braze-sdk/license)](https://packagist.org/packages/immobiliarelabs/braze-sdk) \n[![PHP Version Require](https://poser.pugx.org/immobiliarelabs/braze-sdk/require/php)](https://packagist.org/packages/immobiliarelabs/braze-sdk)\n\n\u003e A PHP client to interact with Braze API\n\n[Braze](https://www.braze.com/) offers a cloud-based customer engagement platform for multichannel marketing. This SDK allows you to integrate its REST API into a PHP application.\n\n## Table of Contents\n\n- [Features](#features)\n- [Install](#install)\n- [Usage](#usage)\n  - [Example](#example)\n  - [Endpoints](#endpoints)\n  - [Validation and dry-run](#validation-and-dry-run)\n  - [HTTP client adapter](#http-client-adapter)\n  - [Parallel requests](#parallel-requests)\n- [Compatibility](#compatibility)\n- [Requirements](#requirements)\n- [Powered Apps](#powered-apps)\n- [Contributing](#contributing)\n- [Changelog](#changelog)\n- [License](#license)\n\n## Features\n\n- Explicit representation of the API contract to write requests easily using the IDE autocomplete\n- Formal validation (strict and non-strict) of requests\n- Dry-run mode to simulate requests and validate them without actually performing calls\n- Ability to use any http client via an adapter. For PSR-18 compatible clients and the Symfony client, adapters are included in the SDK\n- Parallel API calls supported if the http client allows it (for example the Symfony one)\n\n## Install\n\nAdd the SDK as a dependency running:\n\n```bash\ncomposer require immobiliarelabs/braze-sdk\n```\n\nIf not already included in your project, to make http requests, you need to install any combination of packages that implements:\n- [`psr/http-client-implementation`](https://packagist.org/providers/psr/http-client-implementation) or [`symfony/http-client-contracts`](https://packagist.org/providers/symfony/http-client-contracts)\n- [`psr/http-factory-implementation`](https://packagist.org/providers/psr/http-factory-implementation)\n- [`psr/http-message-implementation`](https://packagist.org/providers/psr/http-message-implementation)\n\nfor example by installing ```symfony/http-client``` and ```nyholm/psr7``` you are ready to use the SDK, also with parallel requests.\n\nAlternatively, it is also possible to use any http client by creating the appropriate adapter.\n\n\n## Usage\n\n### Example\n\nBefore instantiating the SDK it is necessary to create the http client and its adapter.\n\n```php\nuse ImmobiliareLabs\\BrazeSDK\\ClientAdapter\\SymfonyAdapter;\nuse Symfony\\Component\\HttpClient\\HttpClient;\n\n$client = HttpClient::create();\n$adapter = new SymfonyAdapter($client);\n```\n\nThis example is for the Symfony http client, but the flow is the same whether you are using a PSR-18 client or a custom one.\nThen you can create the SDK instance.\n\n```php\nuse ImmobiliareLabs\\BrazeSDK\\Braze;\nuse ImmobiliareLabs\\BrazeSDK\\Region;\n\n$braze = new Braze($adapter, 'my-api-key', Region::EU01);\n```\n\nNow you can start making requests by creating one and passing it to the appropriate endpoint. \n\n```php\nuse ImmobiliareLabs\\BrazeSDK\\Object\\Event;\nuse ImmobiliareLabs\\BrazeSDK\\Request\\Users\\TrackRequest;\n\n$event = new Event();\n$event-\u003eexternal_id = 'user-id';\n$event-\u003eapp_id = 'app-id';\n$event-\u003ename = 'event-name';\n$event-\u003etime = new \\DateTimeImmutable();\n$event-\u003eproperties = ['property' =\u003e 'property-value'];\n\n$request = new TrackRequest();\n$request-\u003eevents = [$event];\n\n$response = $braze-\u003eusers()-\u003etrack($request, false);\n```\n\nYou can also set connection and overall timeout.\n\n```php\n$braze-\u003esetConnectionTimeout(2.0);\n$braze-\u003esetOverallTimeout(3.0);\n```\n\nCurrently, SymfonyAdapter supports them, while Psr18Adapter does not.\n\nYou can see a few complete [examples](./examples) in the repository.\n\n### Custom user attributes\n\nTo set custom User attributes use the ```setCustomAttribute``` or ```setCustomAttributes``` methods available in the ```UserAttributes``` class.\n\n```php\nuse ImmobiliareLabs\\BrazeSDK\\Object\\UserAttributes;\n\n$userAttributes = new UserAttributes();\n$userAttributes-\u003eexternal_id = 'user-id';\n$userAttributes-\u003efirst_name = 'Name';\n\n$userAttributes-\u003esetCustomAttribute('custom_int_property', 47);\n\n$userAttributes-\u003esetCustomAttributes([\n    'custom_string_property' =\u003e 'properyValue',\n    'custom_bool_property' =\u003e false,\n]);\n\n$request = new TrackRequest();\n$request-\u003eattributes = [$userAttributes];\n\n$response = $braze-\u003eusers()-\u003etrack($request, false);\n```\n\n### Endpoints\nEndpoints are organized by url prefix. The SDK supports all the Braze endpoints:\n- users\n- campaigns\n- canvas\n- messages\n- content_blocks\n- templates\n- email\n- events\n- feed\n- purchases\n- sessions\n- sends\n- transactional\n- subscription\n\n### Validation and dry-run\nThe SDK does a formal validation of the request before executing it.\nIt is however possible to disable it completely:\n\n```php\n$braze-\u003esetValidation(false);\n```\n\nor just the strict one, since Braze partially executes requests when possible:\n\n```php\n$braze-\u003esetValidation(true, false);\n```\n\nBy default, the SDK performs strict validation.\n\nIf you want to validate your requests without sending them to Braze you can enable dry-run mode:\n\n```php\n$braze-\u003esetDryRun(true);\n```\n\n### HTTP client adapter\n\nIf, in your project, you already have a http client which does not implement one of the two supported interfaces (Symfony and PSR18), \nand you don't want to install another one, just define an adapter that implements the ```ImmobiliareLabs\\BrazeSDK\\ClientAdapter\\ClientAdapterInterface``` interface, \nand use it when instantiate the SDK.\n\n### Parallel requests\n\nIf the chosen http client supports asynchronous calls, you can exploit that to make parallel requests to Braze in this way:\n\n```php\n$response1 = $braze-\u003eusers()-\u003etrack($request1, true);\n$response2 = $braze-\u003eusers()-\u003etrack($request2, true);\n\n$braze-\u003eflush();\n```\n\nThe response objects will be filled with the values obtained only after the call to flush.\n\n## Compatibility\n\n| Version | Status       | PHP compatibility | \n|---------|--------------|-------------------|\n| 1.x     | unmaintained | `\u003e=7.2`           |\n| 2.x     | maintained   | `\u003e=8.0`           |\n| 3.x     | maintained   | `\u003e=8.1`           |\n\n## Requirements\n\n* ext-json\n\n## Powered Apps\n\nBraze PHP SDK was created by the PHP team at [ImmobiliareLabs](https://labs.immobiliare.it/), the Tech dept of [Immobiliare.it](https://www.immobiliare.it), the #1 real estate company in Italy.\n\nWe are currently using this SDK to stay in touch with our users.\n\n**If you are using Braze PHP SDK in production [drop us a message](mailto:opensource@immobiliare.it)**.\n\n## Contributing\n\nAny questions, bug reports or suggestions for improvement are very welcome. See the [contributing](./CONTRIBUTING.md) file for details on how to contribute.\n\n\n## Changelog\n\nPlease refer to the [changelog notes](CHANGELOG.md).\n\n## License\n\nBraze PHP SDK is licensed under the MIT license.  \nSee the [LICENSE](./LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimmobiliare%2Fbraze-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimmobiliare%2Fbraze-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimmobiliare%2Fbraze-php-sdk/lists"}