承接 doniyor/bitrix24-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

doniyor/bitrix24-laravel

最新稳定版本:4.0

Composer 安装命令:

composer require doniyor/bitrix24-laravel

包简介

Laravel integration for the Bitrix24 REST API with CRM entity helpers.

README 文档

README

Laravel wrapper around the Bitrix24 REST API with a focus on CRM entities.

Installation

composer require doniyor/bitrix24-laravel

Publish configuration:

php artisan vendor:publish --tag=bitrix24-config

Configure the following environment variables:

BITRIX24_BASE_URI="https://your-domain.bitrix24.com/rest/"
BITRIX24_WEBHOOK_USER=1
BITRIX24_WEBHOOK_CODE=abcdefghijklmno
# Optional when using OAuth:
# BITRIX24_AUTH_TOKEN="oauth_access_token"

Authentication

  • Incoming webhook: supply BITRIX24_BASE_URI, BITRIX24_WEBHOOK_USER, and BITRIX24_WEBHOOK_CODE. Requests are routed to {base}/{user}/{code}/{method}.json automatically. Leave the auth token unset.
  • OAuth: omit webhook credentials and provide BITRIX24_AUTH_TOKEN. The client sends the token as the auth query parameter.

If both webhook credentials and an auth token are present, the webhook path takes precedence.

Usage

Access the manager with dependency injection:

use Doniyor\Bitrix24\Bitrix24Manager;
use Doniyor\Bitrix24\DTO\CRM\LeadFieldsDto;

public function __construct(private Bitrix24Manager $bitrix) {}

public function createLead(): int
{
    return $this->bitrix->crm()->leads()->add(
        new LeadFieldsDto(
            title: 'New lead',
            name: 'Jane',
            lastName: 'Doe',
            phones: [
                ['VALUE' => '+123456789', 'VALUE_TYPE' => 'WORK'],
            ],
            emails: [
                ['VALUE' => 'jane@example.com', 'VALUE_TYPE' => 'WORK'],
            ],
        )
    );
}

Or via the facade:

use Doniyor\Bitrix24\Facades\Bitrix24;
use Doniyor\Bitrix24\DTO\CRM\LeadFieldsDto;

$lead = Bitrix24::crm()->leads()->get(42);

Bitrix24::crm()->leads()->update(
    42,
    (new LeadFieldsDto(title: 'Existing lead'))
        ->withExtra(['STATUS_ID' => 'CONVERTED'])
);

Supported CRM services

  • Leads
  • Deals
  • Contacts
  • Companies
  • Products
  • Product Sections
  • Quotes
  • Invoices
  • Activities
  • Requisites
  • Deal Categories
  • Statuses
  • Stages
  • Currencies

For other CRM entities, use Bitrix24::crm()->service('entityName').

Field DTOs

  • All add and update operations expect an implementation of Doniyor\Bitrix24\DTO\FieldsDtoInterface.
  • Use any of the ready-made CRM DTOs for type-safe payloads:
    • Doniyor\Bitrix24\DTO\CRM\LeadFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\DealFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\ContactFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\CompanyFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\ProductFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\ProductSectionFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\QuoteFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\InvoiceFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\ActivityFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\RequisiteFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\DealCategoryFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\StatusFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\StageFieldsDto
    • Doniyor\Bitrix24\DTO\CRM\CurrencyFieldsDto
  • Use Doniyor\Bitrix24\DTO\GenericFieldsDto for quick array-backed payloads.
  • Create your own DTO classes to add validation, defaults, or IDE type safety before making requests.

Response DTOs & Mappers

  • Services still return the raw Bitrix24 payload arrays so you can keep existing behaviour.
  • When you want typed objects, use the dedicated mappers:
    • Doniyor\Bitrix24\CRM\Mappers\LeadResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\LeadData
    • Doniyor\Bitrix24\CRM\Mappers\DealResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\DealData
    • Doniyor\Bitrix24\CRM\Mappers\ContactResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\ContactData
    • Doniyor\Bitrix24\CRM\Mappers\CompanyResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\CompanyData
    • Doniyor\Bitrix24\CRM\Mappers\ProductResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\ProductData
    • Doniyor\Bitrix24\CRM\Mappers\ProductSectionResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\ProductSectionData
    • Doniyor\Bitrix24\CRM\Mappers\QuoteResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\QuoteData
    • Doniyor\Bitrix24\CRM\Mappers\InvoiceResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\InvoiceData
    • Doniyor\Bitrix24\CRM\Mappers\ActivityResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\ActivityData
    • Doniyor\Bitrix24\CRM\Mappers\RequisiteResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\RequisiteData
    • Doniyor\Bitrix24\CRM\Mappers\DealCategoryResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\DealCategoryData
    • Doniyor\Bitrix24\CRM\Mappers\StatusResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\StatusData
    • Doniyor\Bitrix24\CRM\Mappers\StageResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\StageData
    • Doniyor\Bitrix24\CRM\Mappers\CurrencyResponseMapperDoniyor\Bitrix24\DTO\CRM\Response\CurrencyData
  • Example usage:
use Doniyor\Bitrix24\Facades\Bitrix24;
use Doniyor\Bitrix24\CRM\Mappers\LeadResponseMapper;

$payload = Bitrix24::crm()->leads()->get(42);
$lead = app(LeadResponseMapper::class)->map($payload);

echo $lead->title;

Bitrix24RestApi

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-20