Download the PHP package bitrix24/b24phpsdk without Composer
On this page you can find all versions of the php package bitrix24/b24phpsdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package b24phpsdk
Bitrix24 REST API PHP SDK
An official PHP library for the Bitrix24 REST API
Build status
CI\CD status on master |
---|
Integration tests run in GitHub actions with real Bitrix24 portal
Installation
Install the latest version with
If You work on Windows:
- please use WSL - Windows Subsystem for Linux
- if your filesystem is NTFS, You can disable flag
git config --global core.protectNTFS false
for checkout folders started with dot.
Or add "bitrix24/b24phpsdk": "1.2.*"
to composer.json
of your application.
B24PhpSdk ✨FEATURES✨
Support both auth modes:
- [x] work with auth tokens for mass-market Bitrix24 applications
- [x] work with incoming webhooks for simple integration projects for a single Bitrix24 account
Domain core events:
- [x] Access Token expired
- [x] Url of a Bitrix24 account domain changed
API - level features
- [x] Auto renew access tokens
- [x] List queries with «start=-1» support
- [ ] offline queues
Performance improvements 🚀
- [x] Batch queries implemented with PHP Generators – constant low memory and low CPI usage:
- [x] batch read data from bitrix24
- [x] batch write data to bitrix24
- [x] read without count flag
Development principles
- Good developer experience
- auto-completion of methods at the IDE
- typed method call signatures
- typed results of method calls
- helpers for typical operations
- Good documentation
- documentation on the operation of a specific method containing a link to the official documentation
- documentation for working with the SDK
- Performance first:
- minimal impact on client code
- ability to work with large amounts of data with constant memory consumption
- efficient operation of the API using batch requests
- Modern technology stack
- based on Symfony HttpClient
- actual PHP versions language features
- Reliable:
- test coverage: unit, integration, contract
- typical examples typical for different modes of operation and they are optimized for memory \ performance
Architecture
Abstraction layers
Documentation
- Bitrix24 API documentation - English
- Internal documentation for B24PhpSdk
Requirements
- php: >=8.2
- ext-json: *
- ext-curl: *
Examples
Work with webhook
- Go to
/examples/webhook
folder -
Open console and install dependencies
- Open Bitrix24 account: Developer resources → Other → Inbound webhook
-
Open example file and insert webhook url into
$webhookUrl
- Call php file in shell
Work with local application
- Go to
/examples/local-app
folder -
Open console and install dependencies
-
Start local development server
-
Expose local server to public via ngrok and remember temporally public url –
https://****.ngrok-free.app
-
Check public url from ngrok and see
x-powered-by
header with 200 status-code. - Open Bitrix24 account: Developer resources → Other → Local application and create new local application:
type
: serverhandler path
:https://****.ngrok-free.app/index.php
Initial installation path
:https://****.ngrok-free.app/install.php
Menu item text
:Test local app
scope
:crm
- Save application parameters in
index.php
file:Application ID (client_id)
—BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID
Application key (client_secret)
—BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET
Assing permitions (scope)
—BITRIX24_PHP_SDK_APPLICATION_SCOPE
see index.php file
- Save local application in Bitrix24 tab and press «OPEN APPLICATION» button.
Create application for Bitrix24 marketplace
if you want to create application you can use production-ready contracts in namespace
Bitrix24\SDK\Application\Contracts
:
Bitrix24Accounts
— Store auth tokens and provides methods for work with Bitrix24 account.ApplicationInstallations
— Store information about application installation, linked with Bitrix24 Account with auth tokens. Optional can store links to:- Client contact person: client person who responsible for application usage
- Bitrix24 Partner contact person: partner contact person who supports client and configure application
- Bitrix24 Partner: partner who supports client portal
ContactPersons
– Store information about person who installed application.Bitrix24Partners
– Store information about Bitrix24 Partner who supports client portal and install or configure application.
Steps:
- Create own entity of this bounded contexts.
- Implement all methods in contract interfaces.
- Test own implementation behavior with contract-tests
tests/Unit/Application/Contracts/*
– examples.
Tests
Tests locate in folder tests
and we have two test types.
In folder tests create file .env.local
and fill environment variables from .env
.
PHP Static Analysis Tool – phpstan
Call in command line
PHP Static Analysis Tool – rector
Call in command line for validate
Call in command line for fix codebase
Unit tests
Fast, in-memory tests without a network I\O For run unit tests you must call in command line
Integration tests
Slow tests with full lifecycle with your test Bitrix24 account via webhook.
❗️Do not run integration tests with production Bitrix24 accounts
For running integration test you must:
- Create new Bitrix24 account for development tests.
- Go to left menu, click «Sitemap».
- Find menu item «Developer resources».
- Click on menu item «Other».
- Click on menu item «Inbound webhook».
- Assign all permisions with webhook and click «save» button.
-
Create file
/tests/.env.local
with same settings, see comments in/tests/.env
file. - call in command line
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub
License
B24PhpSdk is licensed under the MIT License - see the MIT-LICENSE.txt
file for details
All versions of b24phpsdk with dependencies
ext-json Version *
ext-curl Version *
ext-intl Version *
psr/log Version ^2 || ^3
fig/http-message-util Version ^1
giggsey/libphonenumber-for-php Version ^8
darsyn/ip Version ^4 || ^5
nesbot/carbon Version ^3
moneyphp/money Version ^3 || ^4
mesilov/moneyphp-percentage Version ^0.2
symfony/http-client Version ^6 || ^7
symfony/console Version ^6 || ^7
symfony/dotenv Version ^6 || ^7
symfony/filesystem Version ^6 || ^7
symfony/mime Version ^6 || ^7
symfony/finder Version ^6 || ^7
symfony/http-client-contracts Version ^2 || ^3
symfony/http-foundation Version ^6 || ^7
symfony/event-dispatcher Version ^6 || ^7
symfony/uid Version ^6 || ^7