Download the PHP package code-matic/opencdp-php without Composer
On this page you can find all versions of the php package code-matic/opencdp-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code-matic/opencdp-php
More information about code-matic/opencdp-php
Files in code-matic/opencdp-php
Package opencdp-php
Short Description PHP SDK for Codematic's Customer Data Platform (CDP) with optional Customer.io integration
License MIT
Homepage https://docs.opencdp.io/
Informations about the package opencdp-php
Codematic OpenCDP PHP SDK
A PHP client library for Codematic's Customer Data Platform (CDP) with optional Customer.io integration.
See the CDP Documentation for more information.
Installation
Requirements
- PHP 8.0 or higher
- The
curlPHP extension. Message sends use cURL's error codes to tell a host that was never reached (safe to retry on a fallback host) from one that may already have queued the message. - Guzzle HTTP client (automatically installed)
Optional Dependencies
customerio/customerio-php- Required for dual-write functionality to Customer.io
Features
- Send customer identification and event data to Codematic CDP
- Send transactional emails (transactional messaging and raw HTML)
- Send SMS messages
- Send push notifications
- Optional dual-write capability to Customer.io
- Comprehensive error handling and logging
- Full type safety with PHP 8.0+ features
Quick Start
Configuration
Usage Examples
Identify a Person
Track an Event
Register a Device
Send Transactional Email (Using Template)
Send Transactional Email (With Subject & Body Override)
Send Raw Email (Without Template)
Send Email with Attachments
Attach up to 5 files (2 MB decoded in total). SendEmailRequest is immutable, so withAttachment() and withAttachmentFile() return a new request; content is base64-encoded for you:
You can also pass 'attachments' => ['invoice.pdf' => '<base64>'] to the constructor. sendEmail() validates attachments before sending: at most 5 files, at most 2 MB decoded in total, filenames without /, \ or .., and non-empty base64 content. The content type is inferred from the file extension.
Send Push Notification
Send Push with Message Data
Send SMS
Send WhatsApp
- A successful response means the message was queued, not delivered. Delivery runs asynchronously, so a missing WhatsApp provider, no phone number, or a template rejected by Meta does not fail this call. The response holds the transactional execution record; keep its id to trace the send.
template_variables(['header' => [...], 'body' => [...], 'button' => [...]]) sets the template slots from code. Keys must be slot numbers ('1','2', ...), so plain lists like['Jane', '123']are rejected. Values may use Liquid such as{{customer.first_name}}. Passing it replaces all variables saved on the transactional, so include every section the template needs.message_datais available in the template as{{trigger.<key>}}.- Sends are not retried on another gateway host after a timeout or an HTTP error, because the message may already have been queued. The exceptions are connection failures and the Cloudflare errors 521, 523, 525 and 526, which mean the gateway never received the request.
Dual-write to Customer.io
Error Handling
By default, the SDK logs errors but doesn't throw exceptions. You can enable exception throwing:
Note on Return Types:
- Methods
identify(),track(), andregisterDevice()returnvoid. WhenfailOnExceptionisfalse, errors are logged but no exception is thrown. - Methods
sendEmail(),sendPush(),sendSms(), andsendWhatsApp()returnarray. WhenfailOnExceptionisfalseand an error occurs, they return an error array with'ok' => falseand an'error'key containing error details.
Exception Types
CDPException- Base exception for all CDP errorsCDPEmailException- Email sending failuresCDPPushException- Push notification failuresCDPSmsException- SMS sending failures
Debug Mode
Enable debug logging to see detailed information about SDK operations:
This will log all requests, responses, and errors using PHP's error_log().
Custom Logger
Provide your own logger implementation:
Unsupported Email Fields
Some email fields are accepted by the SDK but not yet processed by the backend. The SDK will log a warning when these are used:
send_at- Scheduled send timesend_to_unsubscribed- Send to unsubscribed userstracked- Email trackingdisable_css_preprocessing- CSS preprocessing controlheaders- Custom email headersdisable_message_retention- Message retention controlqueue_draft- Queue as draftfake_bcc- Fake BCC functionalityreply_to- Reply-to addresspreheader- Email preheader text
These fields are included for future compatibility but currently have no effect on email delivery.
Testing Connection
Test your CDP connection:
Development
Running Tests
Code Quality
License
MIT
Support
For questions and support, visit https://docs.opencdp.io/ or contact [email protected]