| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A powerful PHP library for the Bitrix24 REST API
| CI\CD status on master |
|---|
Integration tests run in GitHub actions with real Bitrix24 portal
Support both auth modes:
Domain core events:
API - level features
Performance improvements 🚀
- http2 protocol via json data structures
- symfony http client
- \Bitrix24\SDK\Core\ApiClient - work with b24 rest-api endpoints
input: arrays \ strings
output: Symfony\Contracts\HttpClient\ResponseInterface, operate with strings
process: network operations
- \Bitrix24\SDK\Services\* - work with b24 rest-api entities
input: arrays \ strings
output: b24 response dto
process: b24 entities, operate with immutable objects
Add "mesilov/bitrix24-php-sdk": "2.x" to composer.json of your application. Or clone repo to your project.
composer installdeclare(strict_types=1);
use Bitrix24\SDK\Services\ServiceBuilderFactory;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Processor\MemoryUsageProcessor;
require_once 'vendor/autoload.php';
$webhookUrl = 'INSERT_HERE_YOUR_WEBHOOK_URL';
$log = new Logger('bitrix24-php-sdk');
$log->pushHandler(new StreamHandler('bitrix24-php-sdk.log'));
$log->pushProcessor(new MemoryUsageProcessor(true, true));
// create service builder factory
$b24ServiceFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);
// init bitrix24-php-sdk service from webhook
$b24Service = $b24ServiceFactory->initFromWebhook($webhookUrl);
// work with interested scope
var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile());
// get deals list and address to first element
var_dump($b24Service->getCRMScope()->lead()->list([], [], ['ID', 'TITLE'])->getLeads()[0]->TITLE);php -f example.phpcomposer installsudo php -S 127.0.0.1:80ngrok http 127.0.0.1curl https://****.ngrok-free.app -I
HTTP/2 200
content-type: text/html; charset=UTF-8
date: Mon, 26 Aug 2024 19:09:24 GMT
host: ****.ngrok-free.app
x-powered-by: PHP/8.3.8declare(strict_types=1);
use Bitrix24\SDK\Core\Credentials\AuthToken;
use Bitrix24\SDK\Core\Credentials\ApplicationProfile;
use Bitrix24\SDK\Services\ServiceBuilderFactory;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\MemoryUsageProcessor;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
require_once 'vendor/autoload.php';
?>
<pre>
Application is worked, auth tokens from bitrix24:
<?= print_r($_REQUEST, true) ?>
</pre>
<?php
$request = Request::createFromGlobals();
$log = new Logger('bitrix24-php-sdk');
$log->pushHandler(new StreamHandler('bitrix24-php-sdk.log'));
$log->pushProcessor(new MemoryUsageProcessor(true, true));
$b24ServiceBuilderFactory = new ServiceBuilderFactory(new EventDispatcher(), $log);
$appProfile = ApplicationProfile::initFromArray([
'BITRIX24_PHP_SDK_APPLICATION_CLIENT_ID' => 'INSERT_HERE_YOUR_DATA',
'BITRIX24_PHP_SDK_APPLICATION_CLIENT_SECRET' => 'INSERT_HERE_YOUR_DATA',
'BITRIX24_PHP_SDK_APPLICATION_SCOPE' => 'INSERT_HERE_YOUR_DATA'
]);
$b24Service = $b24ServiceBuilderFactory->initFromRequest($appProfile, AuthToken::initFromPlacementRequest($request), $request->get('DOMAIN'));
var_dump($b24Service->getMainScope()->main()->getCurrentUserProfile()->getUserProfile());
// get deals list and address to first element
var_dump($b24Service->getCRMScope()->lead()->list([], [], ['ID', 'TITLE'])->getLeads()[0]->TITLE);if you want to create application you can use production-ready contracts in namespace Bitrix24\SDK\Application\Contracts:
Steps:
Tests locate in folder tests and we have two test types. In folder tests create file .env.local and fill environment variables from .env.
Call in command line
make lint-phpstanCall in command line for validate
make lint-rectorCall in command line for fix codebase
make lint-rector-fixFast, in-memory tests without a network I\O For run unit tests you must call in command line
make test-unitSlow tests with full lifecycle with your test Bitrix24 portal via webhook.
❗️Do not run integration tests with production portals
For run integration test you must:
APP_ENV=dev
BITRIX24_WEBHOOK=https:// your portal webhook url
INTEGRATION_TEST_LOG_LEVEL=500make test-integration-core
make test-integration-scope-telephony
make test-integration-scope-workflows
make test-integration-scope-userBugs and feature request are tracked on GitHub
bitrix24-php-sdk is licensed under the MIT License - see the MIT-LICENSE.txt file for details
Maksim Mesilov - mesilov.maxim@gmail.com
See also the list of contributors which participated in this project.
Email to mesilov.maxim@gmail.com for private consultations or dedicated support.
| Back | FazBrowse Home | New Git URL |