{"id":19294719,"url":"https://github.com/moesif/moesif-symfony","last_synced_at":"2026-01-02T21:57:27.318Z","repository":{"id":228581570,"uuid":"773947974","full_name":"Moesif/moesif-symfony","owner":"Moesif","description":"Moesif Symfony SDK, for API Monitoring, Analytics, and Monetization.","archived":false,"fork":false,"pushed_at":"2024-09-04T13:28:10.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-16T01:53:15.496Z","etag":null,"topics":["analytics","api-analytics","api-logs","api-management","api-monetization","api-monitoring","logger","logging","monitoring","observability","php","php-symfony","symfony","symfony5","usage-based-billing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Moesif.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2024-03-18T17:16:15.000Z","updated_at":"2024-09-04T13:28:14.000Z","dependencies_parsed_at":"2024-09-05T16:08:06.635Z","dependency_job_id":null,"html_url":"https://github.com/Moesif/moesif-symfony","commit_stats":null,"previous_names":["moesif/moesif-symfony"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moesif%2Fmoesif-symfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moesif%2Fmoesif-symfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moesif%2Fmoesif-symfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moesif%2Fmoesif-symfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moesif","download_url":"https://codeload.github.com/Moesif/moesif-symfony/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250205978,"owners_count":21392159,"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":["analytics","api-analytics","api-logs","api-management","api-monetization","api-monitoring","logger","logging","monitoring","observability","php","php-symfony","symfony","symfony5","usage-based-billing"],"created_at":"2024-11-09T22:39:25.581Z","updated_at":"2025-11-11T20:10:09.186Z","avatar_url":"https://github.com/Moesif.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moesif Symfony SDK Documentation\nby [Moesif](https://moesif.com), the [API analytics](https://www.moesif.com/features/api-analytics) and [API monetization](https://www.moesif.com/solutions/metered-api-billing) platform.\n\n[Moesif's official SDK for PHP Symfony](https://github.com/Moesif/moesif-symfony) allows you to automatically capture API traffic and send to the [Moesif API Analytics](https://www.moesif.com/docs/api-analytics/) platform.\n\n\u003e If you're new to Moesif, see [our Getting Started](https://www.moesif.com/docs/) resources to quickly get up and running.\n\n## Supported Symfony Versions\nThe SDK currently supports all Symfony 5.x versions.\n\n## Prerequisites\nBefore using this SDK, make sure you have the following:\n\n- [An active Moesif account](https://moesif.com/wrap)\n- [A Moesif Application ID](#get-your-moesif-application-id)\n\n### Get Your Moesif Application ID\nAfter you log into [Moesif Portal](https://www.moesif.com/wrap), you can get your Moesif Application ID during the onboarding steps. You can always access the Application ID any time by following these steps from Moesif Portal after logging in:\n\n1. Select the account icon to bring up the settings menu.\n2. Select **Installation** or **API Keys**.\n3. Copy your Moesif Application ID from the **Collector Application ID** field.\n\n\u003cimg class=\"lazyload blur-up\" src=\"images/app_id.png\" width=\"700\" alt=\"Accessing the settings menu in Moesif Portal\"\u003e\n\n## Install the SDK\nMoesif Symfony SDK is available through [Composer](https://getcomposer.org/), the dependency manager for PHP. After you have Composer installed, execute the following command:\n\n```bash\n$ composer require moesif/moesif-symfony\n```\n \nOtherwise, manually add `moesif/moesif-symfony` to your [`composer.json` file](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup).\n\n## Enable the SDK\nFollow these steps to enable the SDK:\n\n1. In your project's `config/packages` directory, add a `moesif.yaml` file. This file holds your configuration options. \n2. The configuration file requires you to at least [specify your Moesif Application ID](#get-your-moesif-application-id). The following shows an example:\n\n    ``` yaml\n    moesif:\n      moesif_application_id: 'YOUR_MOESIF_APPLICATION_ID.'\n      debug: false\n      options:\n        max_queue_size: 50\n        max_batch_size: 25\n      hooks_class: 'App\\Configuration\\MyMoesifHooks'\n    ```\nFor more configuration options, see [YAML Configuration Options](#configuration-options).\n\n## Configure the SDK\nSee the available [configuration options](#configuration-options) to learn how to configure the SDK for your use case.\n\n## Troubleshoot\nFor a general troubleshooting guide that can help you solve common problems, see [Server Troubleshooting Guide](https://www.moesif.com/docs/troubleshooting/server-troubleshooting-guide/). \n\nOther troubleshooting supports:\n\n- [FAQ](https://www.moesif.com/docs/faq/)\n- [Moesif support email](mailto:support@moesif.com)\n\n## Configuration Options\nThe following sections describe the available configuration options that you can define in `moesif.yaml`.\n\n### `applicationId` (Required)\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eString\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\nA string that identifies your application..\n\n\n### `debug`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003ebool\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nSet to `true` to print debug messages into the debug and error logs. This can help you troubleshoot integration issues.\n\n### `options`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eObject\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nIf set, contains various options to configure the SDK beyond the defaults.\n\nIn this object, you can set the following options:\n\n#### `max_queue_size`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Default\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eInteger\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e15\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nIf set, overrides the default `max_queue_size` before sending data to Moesif.\n\n#### `max_batch_size`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Default\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eInteger\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e10\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nIf set, overrides the default `max_batch_size` that is sent over to Moesif.\n\n#### `hooks_class`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eString\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nIf set, this must be [your implementation of `MoesifHooksInterface`](#user-hook-class-options).\n\n### User Hook Class Options\n\nYou can override and customize certain functionalities within the plugin with hooks. For example, create a file `MyMoesifHooks.php` and implement the `MoesifHooksInterface`:\n\n```php\nuse Moesif\\MoesifBundle\\Interfaces\\MoesifHooksInterface;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass MyMoesifHooks implements MoesifHooksInterface {\n   // your implementation of every method follows.\n}\n```\nSee [the Example Implementation](#example-implementation) for an example.\n\nMake sure to set the [`hooks_class`](#hooks_class) configuration option to the path of your implementation file.\n\nThe methods you need to implement for `MoesifHooksInterface` are the following:\n\n#### `identifyUserId`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($request, $response)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eString\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nThis function takes the `$request` and `$response` arguments and returns a string for a user ID. This enables Moesif to attribute API requests to individual unique users so you can understand who calls your API. You can use this simultaneously with [`identifyCompanyId`](#identifycompanyid) to track both individual customers and also the companies they are part of.\n\n#### `identifyCompanyId`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($request, $response)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eString\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional. \n\nThis function takes the `$request` and `$response` arguments and returns a string for a company ID. If you have a B2B business, this method enables Moesif to attribute API requests to specific companies or organizations so you can understand which accounts call your API. You can use this simultaneously with [`identifyUserId`](#identifyuserid) to track both individual customers and the companies they are part of.\n\n#### `identifySessionToken`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($request, $response)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eString\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nA function that takes the `$request` and `$response` arguments and returns a string for session or auth token. Moesif automatically creates sessions by processing your API data, but you can override this through the `identifySessionId` method if you're not happy with the results.\n\n#### `maskRequestHeaders`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($headers)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e$headers\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nA function that takes the `$headers` argument for a request. The argument is an associative array. The method\nreturns an associative array with your sensitive request headers removed or masked.\n\n#### `maskRequestBody`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($body)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e$body\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nA function that takes the `$body` argument for request body. The argument an associative array representation of JSON. The method\nreturns an associative array with any request body information removed.\n\n#### `maskResponseHeaders`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($headers)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e$headers\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nSame as [`maskRequestHeaders`](#maskrequestheaders), but for HTTP responses.\n\n#### `maskResponseBody`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($body)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e$body\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nSame as [`maskResponseBody`](#maskrequestbody), but for HTTP responses.\n\n#### `getMetadata`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($request, $response)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003eAssociative Array\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nA function that takes the `$request` and `$response` arguments and returns `$metadata`. `$metadata` is an associative array representation of JSON.\n\n#### `skip`\n\u003ctable\u003e\n  \u003ctr\u003e\n   \u003cth scope=\"col\"\u003e\n    Data type\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Parameters\n   \u003c/th\u003e\n   \u003cth scope=\"col\"\u003e\n    Return type\n   \u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n   \u003ctd\u003e\n    Function\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003e($request, $response)\u003c/code\u003e\n   \u003c/td\u003e\n   \u003ctd\u003e\n    \u003ccode\u003ebool\u003c/code\u003e\n   \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nOptional.\n\nA function that takes the `$request` and `$response` arguments. Returns `true` if you want to skip the event. Skipping an event means Moesif doesn't log the event.\n\n#### Example Implementation\nThe following example shows what the `MyMoesifHooks.php` file may look like with a `MoesifHooksInterface` implementation:\n\n``` php\n\u003c?php\n\nnamespace App\\Configuration;\n\nuse Moesif\\MoesifBundle\\Interfaces\\MoesifHooksInterface;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\n\nclass MyMoesifHooks implements MoesifHooksInterface {\n\n  public function __construct() {\n  }\n\n  public function identifyUserId(Request $request, Response $response): string|null\n  {\n    return 'nihao1';\n  }\n\n  public function identifyCompanyId(Request $request, Response $response): string|null\n  {\n    return $request-\u003eheaders-\u003eget('X-Company-Id');\n  }\n\n  public function identifySessionToken(Request $request, Response $response): string|null\n  {\n    return null;\n  }\n\n  public function getMetadata(Request $request, Response $response): ?array\n  {\n      return null;\n  }\n\n  public function skip(Request $request, Response $response): bool\n  {\n      return false;\n  }\n\n  public function maskRequestHeaders(array $headers): array\n  {\n      return $headers;\n  }\n\n  public function maskResponseHeaders(array $headers): array\n  {\n      return $headers;\n  }\n\n  public function maskRequestBody($body)\n  {\n      // this can be a string or array object.\n      // because prior to php 8, can not declare union type (such as string|array)\n      return $body;\n  }\n\n  public function maskResponseBody($body)\n  {\n      // this can be a string or array object.\n      // because prior to php 8, can not declare union type (such as string|array)\n      return $body;\n  }\n}\n```\n## Examples\nThe following examples demonstrate how to add and update customer information.\n\n### Update a Single User\n\nThe following example shows how you can create or update a user profile in Moesif using the `updateUser` function.\n\nThe `metadata` field can contain any customer demographic or other information you want to store.\n\nOnly the `user_id` field is required.\n\nFor more information, see the [PHP API Reference about updating a singer user](https://www.moesif.com/docs/api?php#update-a-user).\n\n```php\n\u003c?php\nuse Moesif\\MoesifBundle\\Service\\MoesifApiService;\n\nprivate $moesifApiService;\n\npublic function __construct(MoesifApiService $moesifApiService)\n{\n    $this-\u003emoesifApiService = $moesifApiService;\n}\n\n// metadata can be any custom object\n$data-\u003emetadata = array(\n    \"email\" =\u003e \"john@acmeinc.com\",\n    \"first_name\" =\u003e \"John\",\n    \"last_name\" =\u003e \"Doe\",\n    \"title\" =\u003e \"Software Engineer\",\n    \"sales_info\" =\u003e array(\n        \"stage\" =\u003e \"Customer\",\n        \"lifetime_value\" =\u003e 24000,\n        \"account_owner\" =\u003e \"mary@contoso.com\"\n    )\n);\n\n$userData = [\n    'user_id' =\u003e $data['userId'],\n    'user_email' =\u003e $data['userEmail'],\n    'company_id' =\u003e $data['companyId'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$this-\u003emoesifApiService-\u003eupdateUser($userData);\n```\n\n### Update Users in Batch\n\nYou can use the `updateUsersBatch` function to update a list of users in one batch.\n\nOnly the `user_id` field is required.\n\nFor more information, see the [PHP API Reference about updating users in batch](https://www.moesif.com/docs/api?php#update-users-in-batch).\n\n```php\n\u003c?php\nuse Moesif\\MoesifBundle\\Service\\MoesifApiService;\n\nprivate $moesifApiService;\n\npublic function __construct(MoesifApiService $moesifApiService)\n{\n    $this-\u003emoesifApiService = $moesifApiService;\n}\n\n// metadata can be any custom object\n$data-\u003emetadata = array(\n    \"email\" =\u003e \"john@acmeinc.com\",\n    \"first_name\" =\u003e \"John\",\n    \"last_name\" =\u003e \"Doe\",\n    \"title\" =\u003e \"Software Engineer\",\n    \"sales_info\" =\u003e array(\n        \"stage\" =\u003e \"Customer\",\n        \"lifetime_value\" =\u003e 24000,\n        \"account_owner\" =\u003e \"mary@contoso.com\"\n    )\n);\n\n$userDataA = [\n    'user_id' =\u003e $data['userIdA'],\n    'user_email' =\u003e $data['userEmailA'],\n    'company_id' =\u003e $data['companyIdA'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$userDataB = [\n    'user_id' =\u003e $data['userIdB'],\n    'user_email' =\u003e $data['userEmailB'],\n    'company_id' =\u003e $data['companyIdB'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$users = array($userDataA, $userDataB)\n$this-\u003emoesifApiService-\u003eupdateUsersBatch($user);\n```\n\n### Update a Single Company\n\nTo create or update a company profile in Moesif, use the `updateCompany` function.\n\nThe `metadata` field can contain any company demographic or other information you want to store.\n\nOnly the `company_id` field is required.\n\nFor more information, see the [PHP API Reference about updating a single company](https://www.moesif.com/docs/api?php#update-a-company).\n\n```php\n\u003c?php\nuse Moesif\\MoesifBundle\\Service\\MoesifApiService;\n\nprivate $moesifApiService;\n\npublic function __construct(MoesifApiService $moesifApiService)\n{\n    $this-\u003emoesifApiService = $moesifApiService;\n}\n\n// metadata can be any custom object\n$data-\u003emetadata = array(\n    \"org_name\" =\u003e \"Acme, Inc\",\n    \"plan_name\" =\u003e \"Free\",\n    \"deal_stage\" =\u003e \"Lead\",\n    \"mrr\" =\u003e 24000,\n    \"demographics\" =\u003e array(\n        \"alexa_ranking\" =\u003e 500000,\n        \"employee_count\" =\u003e 47\n    )\n);\n\n// Prepare company data for Moesif\n$companyData = [\n    'company_id' =\u003e $data['companyId'],\n    'company_domain' =\u003e $data['companyDomain'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$this-\u003emoesifApiService-\u003eupdateCompany($companyData);\n```\n\n### Update Companies in Batch\n\nTo update a list of companies in one batch, use the `updateCompaniesBatch` function.\n\nOnly the `company_id` field is required.\n\nFor more information, see the [PHP API Reference about updating companies in batch](https://www.moesif.com/docs/api?php#update-companies-in-batch).\n\n```php\n\u003c?php\nuse Moesif\\MoesifBundle\\Service\\MoesifApiService;\n\nprivate $moesifApiService;\n\npublic function __construct(MoesifApiService $moesifApiService)\n{\n    $this-\u003emoesifApiService = $moesifApiService;\n}\n\n// metadata can be any custom object\n$data-\u003emetadata = array(\n    \"org_name\" =\u003e \"Acme, Inc\",\n    \"plan_name\" =\u003e \"Free\",\n    \"deal_stage\" =\u003e \"Lead\",\n    \"mrr\" =\u003e 24000,\n    \"demographics\" =\u003e array(\n        \"alexa_ranking\" =\u003e 500000,\n        \"employee_count\" =\u003e 47\n    )\n);\n\n// Prepare company data for Moesif\n$companyDataA = [\n    'company_id' =\u003e $data['companyIdA'],\n    'company_domain' =\u003e $data['companyDomainA'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$companyDataB = [\n    'company_id' =\u003e $data['companyIdB'],\n    'company_domain' =\u003e $data['companyDomainB'],\n    'metadata' =\u003e $data['metadata'] ?? [], // Include metadata if provided\n    // Add more fields as needed\n];\n\n$companies = array($companyDataA, $companyDataB)\n\n$this-\u003emoesifApiService-\u003eupdateCompaniesBatch($companies);\n```\n\n## How to Get Help\nIf you face any issues using this SDK, try the [troubheshooting guidelines](#troubleshoot). For further assistance, reach out to our [support team](mailto:support@moesif.com).\n\n## Explore Other Integrations\n\nExplore other integration options from Moesif:\n\n- [Server integration options documentation](https://www.moesif.com/docs/server-integration//)\n- [Client integration options documentation](https://www.moesif.com/docs/client-integration/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoesif%2Fmoesif-symfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoesif%2Fmoesif-symfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoesif%2Fmoesif-symfony/lists"}