{"id":13435416,"url":"https://github.com/mesilov/bitrix24-php-sdk","last_synced_at":"2025-04-14T18:16:00.145Z","repository":{"id":37580044,"uuid":"14074077","full_name":"mesilov/bitrix24-php-sdk","owner":"mesilov","description":"A powerful PHP library for the Bitrix24 REST API","archived":true,"fork":false,"pushed_at":"2025-02-07T19:55:54.000Z","size":1618,"stargazers_count":412,"open_issues_count":0,"forks_count":162,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-04-14T18:15:53.840Z","etag":null,"topics":["bitrix24","bitrix24-library","hacktoberfest","php","rest-api","sdk"],"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/mesilov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://boosty.to/bitrix24-php-sdk"]}},"created_at":"2013-11-02T20:04:58.000Z","updated_at":"2025-03-20T11:05:42.000Z","dependencies_parsed_at":"2023-02-16T08:00:54.389Z","dependency_job_id":"da59124a-53af-4931-9eff-2de71d1a6efb","html_url":"https://github.com/mesilov/bitrix24-php-sdk","commit_stats":{"total_commits":472,"total_committers":34,"mean_commits":"13.882352941176471","dds":0.3029661016949152,"last_synced_commit":"888c4a1f52596981b7f687094563fc87a8884d5d"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesilov%2Fbitrix24-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesilov%2Fbitrix24-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesilov%2Fbitrix24-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesilov%2Fbitrix24-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesilov","download_url":"https://codeload.github.com/mesilov/bitrix24-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933344,"owners_count":21185460,"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":["bitrix24","bitrix24-library","hacktoberfest","php","rest-api","sdk"],"created_at":"2024-07-31T03:00:35.514Z","updated_at":"2025-04-14T18:16:00.028Z","avatar_url":"https://github.com/mesilov.png","language":"PHP","funding_links":["https://boosty.to/bitrix24-php-sdk"],"categories":["\u003ca id=\"repos-organization\"\u003eGithub, Bitbucket, etc\u003c/a\u003e"],"sub_categories":["Репозитории"],"readme":"❗️Bitrix24 forked this repository 🥳 and now I contribute [there](https://github.com/bitrix24/b24phpsdk)\n================\n\n❗️For new and existing projects please use https://github.com/bitrix24/b24phpsdk\n================\n\nBitrix24 REST API PHP SDK\n================\n[![License](https://poser.pugx.org/mesilov/bitrix24-php-sdk/license.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk) [![Total Downloads](https://poser.pugx.org/mesilov/bitrix24-php-sdk/downloads.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk)\n[![Latest Stable Version](https://img.shields.io/packagist/v/mesilov/bitrix24-php-sdk.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk)\n\nA powerful PHP library for the Bitrix24 REST API\n\n## Build status\n\n| CI\\CD [status](https://github.com/mesilov/bitrix24-php-sdk/actions) on `master`                                                                                                                       | \n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| \n| [![phpstan check](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpstan.yml/badge.svg)](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpstan.yml)                    | \n| [![unit-tests status](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpunit.yml/badge.svg)](https://github.com/mesilov/bitrix24-php-sdk/actions/workflows/phpunit.yml)                | \n\nIntegration tests run in GitHub actions with real Bitrix24 portal\n\n## BITRIX24-PHP-SDK ✨FEATURES✨\n\nSupport both auth modes:\n\n- [x] work with auth tokens for Bitrix24 applications in marketplace\n- [x] work with incoming webhooks for simple integration projects for current portal\n\nDomain core events:\n\n- [x] Access Token expired\n- [x] Bitrix24 portal domain url changed\n\nAPI - level features\n\n- [x] Auto renew access tokens\n- [x] List queries with «start=-1» support\n- [ ] offline queues\n\nPerformance improvements 🚀\n\n- [x] Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) –\n  constant low memory and low CPI usage:\n- [x] batch read data from bitrix24\n- [x] batch write data to bitrix24\n- [x] read without count flag\n\n## Development principles\n\n- Good developer experience\n    - auto-completion of methods at the IDE\n    - typed method call signatures\n    - typed results of method calls\n    - helpers for typical operations\n- Good documentation\n    - documentation on the operation of a specific method containing a link to the official documentation\n    - documentation for working with the SDK\n- Performance first:\n    - minimal impact on client code\n    - ability to work with large amounts of data with constant memory consumption\n    - efficient operation of the API using batch requests\n- Modern technology stack\n    - based on [Symfony HttpClient](https://symfony.com/doc/current/http_client.html)\n    - actual PHP versions language features\n- Reliable:\n    - test coverage: unit, integration, contract\n    - typical examples typical for different modes of operation and they are optimized for memory \\ performance\n\n## Architecture\n\n### Abstraction layers\n\n```\n- http2 protocol via json data structures\n- symfony http client\n- \\Bitrix24\\SDK\\Core\\ApiClient - work with b24 rest-api endpoints\n    input: arrays \\ strings\n    output: Symfony\\Contracts\\HttpClient\\ResponseInterface, operate with strings\n    process: network operations \n- \\Bitrix24\\SDK\\Services\\* - work with b24 rest-api entities\n    input: arrays \\ strings\n    output: b24 response dto\n    process: b24 entities, operate with immutable objects  \n```\n\n## Documentation\n\n- [Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)\n- [Internal documentation](docs/EN/documentation.md) for bitrix24-php-sdk\n\n## Requirements\n\n- php: \u003e=8.2\n- ext-json: *\n- ext-curl: *\n\n## Installation\n\nAdd `\"mesilov/bitrix24-php-sdk\": \"2.x\"` to `composer.json` of your application. Or clone repo to your project.\n\n## Examples\n\n### Work with webhook\n\n1. Go to `/examples/webhook` folder\n2. Open console and install dependencies\n\n```shell\ncomposer install\n```\n\n3. Open Bitrix24 portal: Developer resources → Other → Inbound webhook\n4. Open example file and insert webhook url into `$webhookUrl`\n\n\u003cdetails\u003e\n  \u003csummary\u003esee example.php file\u003c/summary\u003e\n\n```php\ndeclare(strict_types=1);\n\nuse Bitrix24\\SDK\\Services\\ServiceBuilderFactory;\nuse Symfony\\Component\\EventDispatcher\\EventDispatcher;\nuse Monolog\\Logger;\nuse Monolog\\Handler\\StreamHandler;\nuse Monolog\\Processor\\MemoryUsageProcessor;\n\nrequire_once 'vendor/autoload.php';\n\n$webhookUrl = 'INSERT_HERE_YOUR_WEBHOOK_URL';\n\n$log = new Logger('bitrix24-php-sdk');\n$log-\u003epushHandler(new StreamHandler('bitrix24-php-sdk.log'));\n$log-\u003epushProcessor(new MemoryUsageProcessor(true, true));\n\n// create service builder factory\n$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);\n// init bitrix24-php-sdk service from webhook\n$b24Service = $b24ServiceFactory-\u003einitFromWebhook($webhookUrl);\n\n// work with interested scope\nvar_dump($b24Service-\u003egetMainScope()-\u003emain()-\u003egetCurrentUserProfile()-\u003egetUserProfile());\n// get deals list and address to first element\nvar_dump($b24Service-\u003egetCRMScope()-\u003elead()-\u003elist([], [], ['ID', 'TITLE'])-\u003egetLeads()[0]-\u003eTITLE);\n```\n\n\u003c/details\u003e\n\n5. Call php file in shell\n\n```shell\nphp -f example.php\n```\n\n### Work with local application\n\n1. Go to `/examples/local-application` folder\n2. Open console and install dependencies\n\n```shell\ncomposer install\n```\n\n3. Start local development server\n\n```shell\nsudo php -S 127.0.0.1:80\n```\n\n4. Expose local server to public via [ngrok](https://ngrok.com/) and remember temporally public url –\n   `https://****.ngrok-free.app`\n\n```shell\nngrok http 127.0.0.1\n```\n\n5. Check public url from ngrok and see `x-powered-by` header with **200** status-code.\n\n```shell\ncurl https://****.ngrok-free.app -I\nHTTP/2 200 \ncontent-type: text/html; charset=UTF-8\ndate: Mon, 26 Aug 2024 19:09:24 GMT\nhost: ****.ngrok-free.app\nx-powered-by: PHP/8.3.8\n```\n\n6. Open Bitrix24 portal: Developer resources → Other → Local application and create new local application:\n   - `type`: server\n   - `handler path`: `https://****.ngrok-free.app/index.php`\n   - `Initial installation path`: `https://****.ngrok-free.app/install.php`\n   - `Menu item text`: `Test local app`\n   - `scope`: `crm`\n7. Save application parameters in `index.php` file: \n   - `Application ID (client_id)` — `BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID` \n   - `Application key (client_secret)` — `BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET` \n   - `Assing permitions (scope)` — `BITRIX24_PHP_SDK_APPLICATION_SCOPE`\n\u003cdetails\u003e\n  \u003csummary\u003esee index.php file\u003c/summary\u003e\n\n```php\ndeclare(strict_types=1);\n\nuse Bitrix24\\SDK\\Core\\Credentials\\AuthToken;\nuse Bitrix24\\SDK\\Core\\Credentials\\ApplicationProfile;\nuse Bitrix24\\SDK\\Services\\ServiceBuilderFactory;\nuse Monolog\\Handler\\StreamHandler;\nuse Monolog\\Logger;\nuse Monolog\\Processor\\MemoryUsageProcessor;\nuse Symfony\\Component\\EventDispatcher\\EventDispatcher;\nuse Symfony\\Component\\HttpFoundation\\Request;\n\nrequire_once 'vendor/autoload.php';\n?\u003e\n    \u003cpre\u003e\n    Application is worked, auth tokens from bitrix24:\n    \u003c?= print_r($_REQUEST, true) ?\u003e\n\u003c/pre\u003e\n\u003c?php\n$request = Request::createFromGlobals();\n\n$log = new Logger('bitrix24-php-sdk');\n$log-\u003epushHandler(new StreamHandler('bitrix24-php-sdk.log'));\n$log-\u003epushProcessor(new MemoryUsageProcessor(true, true));\n\n$b24ServiceBuilderFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);\n$appProfile = ApplicationProfile::initFromArray([\n    'BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID' =\u003e 'INSERT_HERE_YOUR_DATA',\n    'BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET' =\u003e 'INSERT_HERE_YOUR_DATA',\n    'BITRIX24_PHP_SDK_APPLICATION_SCOPE' =\u003e 'INSERT_HERE_YOUR_DATA'\n]);\n$b24Service = $b24ServiceBuilderFactory-\u003einitFromRequest($appProfile, AuthToken::initFromPlacementRequest($request), $request-\u003eget('DOMAIN'));\n\nvar_dump($b24Service-\u003egetMainScope()-\u003emain()-\u003egetCurrentUserProfile()-\u003egetUserProfile());\n// get deals list and address to first element\nvar_dump($b24Service-\u003egetCRMScope()-\u003elead()-\u003elist([], [], ['ID', 'TITLE'])-\u003egetLeads()[0]-\u003eTITLE);\n```\n\n\u003c/details\u003e\n8. Save local application in Bitrix24 tab and press «OPEN APPLICATION» button.    \n\n\n### Create application for Bitrix24 marketplace\n\nif you want to create application you can use production-ready contracts in namespace\n`Bitrix24\\SDK\\Application\\Contracts`:\n\n- `Bitrix24Accounts` — Store auth tokens and\n  provides [methods](src/Application/Contracts/Bitrix24Accounts/Docs/Bitrix24Accounts.md) for work with Bitrix24\n  account.\n- `ApplicationInstallations` — Store information\n  about [application installation](src/Application/Contracts/ApplicationInstallations/Docs/ApplicationInstallations.md),\n  linked with Bitrix24 Account with auth\n  tokens. Optional can store links to:\n    - Client contact person: client person who responsible for application usage\n    - Bitrix24 Partner contact person: partner contact person who supports client and configure application\n    - Bitrix24 Partner: partner who supports client portal\n- `ContactPersons` – Store information [about person](src/Application/Contracts/ContactPersons/Docs/ContactPersons.md)\n  who installed application.\n- `Bitrix24Partners` – Store information\n  about [Bitrix24 Partner](src/Application/Contracts/Bitrix24Partners/Docs/Bitrix24Partners.md) who supports client\n  portal and install or configure application.\n\nSteps:\n\n1. Create own entity of this bounded contexts.\n2. Implement all methods in contract interfaces.\n3. Test own implementation behavior with contract-tests `tests/Unit/Application/Contracts/*` – examples.\n\n## Tests\n\nTests locate in folder `tests` and we have two test types.\nIn folder tests create file `.env.local` and fill environment variables from `.env`.\n\n### PHP Static Analysis Tool – phpstan\n\nCall in command line\n\n```shell\nmake lint-phpstan\n```\n\n### PHP Static Analysis Tool – rector\n\nCall in command line for validate\n\n```shell\nmake lint-rector\n```\n\nCall in command line for fix codebase\n\n```shell\nmake lint-rector-fix\n```\n\n### Unit tests\n\n**Fast**, in-memory tests without a network I\\O For run unit tests you must call in command line\n\n```shell\nmake test-unit\n```\n\n### Integration tests\n\n**Slow** tests with full lifecycle with your **test** Bitrix24 portal via webhook.\n\n❗️Do not run integration tests with production portals\n\nFor run integration test you must:\n\n1. Create new Bitrix24 portal for development tests.\n2. Go to left menu, click «Sitemap».\n3. Find menu item «Developer resources».\n4. Click on menu item «Other».\n5. Click on menu item «Inbound webhook».\n6. Assign all permisions with webhook and click «save» button.\n7. Create file `/tests/.env.local` with same settings, see comments in `/tests/.env` file.\n\n```yaml\nAPP_ENV=dev\nBITRIX24_WEBHOOK=https:// your portal webhook url\nINTEGRATION_TEST_LOG_LEVEL=500\n```\n\n8. call in command line\n\n```shell\nmake test-integration-core\nmake test-integration-scope-telephony\nmake test-integration-scope-workflows\nmake test-integration-scope-user\n```\n\n## Submitting bugs and feature requests\n\nBugs and feature request are tracked on [GitHub](https://github.com/mesilov/bitrix24-php-sdk/issues)\n\n## License\n\nbitrix24-php-sdk is licensed under the MIT License - see the `MIT-LICENSE.txt` file for details\n\n## Authors\n\nMaksim Mesilov - mesilov.maxim@gmail.com\n\nSee also the list of [contributors](https://github.com/mesilov/bitrix24-php-sdk/graphs/contributors) which participated\nin this project.\n\n## Sponsors\n\n[boosty.to/bitrix24-php-sdk](https://boosty.to/bitrix24-php-sdk)\n\n## Need custom Bitrix24 application?\n\nEmail to mesilov.maxim@gmail.com for private consultations or dedicated support.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesilov%2Fbitrix24-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesilov%2Fbitrix24-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesilov%2Fbitrix24-php-sdk/lists"}