|
1 |
| -# Rollbar PHP Examples: LaunchDarklyTransformer |
| 1 | +# Rollbar PHP Examples: TagsTransformer |
2 | 2 |
|
3 |
| -This project is an example of how to set up a custom transformer for Rollbar |
4 |
| -reporting for your PHP application. We use this functionality to move the extra |
5 |
| -data sent with the payload to the root level under the `tags` object. |
6 |
| - |
7 |
| -## Installation |
8 |
| - |
9 |
| -1. `cp config/secret.example.php config/secret.php` |
10 |
| -2. Fill out `config/secret.php` with your Rollbar server-side access token. |
| 3 | +This project is an example of how to set up a custom transformer to modify the payload sent by the PHP SDK to match |
| 4 | +what is expected from our beta LaunchDarkly integration. The integration is expecting the feature flag key to be sent |
| 5 | +as a tag object in the `tags` section of the payload. By following this example, you should be able to do just that. |
11 | 6 |
|
12 | 7 | ## Steps used in this example
|
13 | 8 | 1. Set up `rollbar/rollbar` as a dependency with `composer require rollbar/rollbar`.
|
14 | 9 | 2a. Create your transformer class in `src/TagsTransformer.php` which implements `TransformerInterface`.
|
15 | 10 | 2b. Create your data class which implements `Data` (is found in `src/TagsTransformer.php`).
|
16 | 11 | 3. Implement `transform` method in your `TagsTransformer` with desired business logic. Make sure you return the $payload object from this method.
|
17 | 12 | 4. Set up Rollbar with your `TagsTransformer` class in `example.php` using `transformer` configuration option.
|
18 |
| -5. Run `composer test` and verify that the extra data is sent under the `tags` key in Rollbar. |
| 13 | +5. Set your API token into the environment. |
| 14 | + On Mac/Linux/UNIX, try `export ROLLBAR_TOKEN=the-access-token`. |
| 15 | + On Windows CMD, use set `ROLLBAR_TOKEN="the-access-token"`. |
| 16 | + For Windows PowerShell, use `$env:ROLLBAR_TOKEN="the-access-token"`. |
| 17 | +6. Run `composer test` and verify that the extra data is sent under the `tags` key in Rollbar. |
19 | 18 |
|
20 | 19 | ## Help / Support
|
21 | 20 |
|
22 | 21 | If you run into any issues, please email us at [support@rollbar.com](mailto:support@rollbar.com)
|
23 | 22 |
|
24 | 23 | ## Testing
|
25 |
| -To run the example: `composer test` |
| 24 | +To run the example: |
| 25 | +Make sure to set your Rollbar API access token in the ROLLBAR_TOKEN environment variable in step 5. |
| 26 | +And then run: `composer test`. |
0 commit comments