Download the PHP package hiroshiaki/datafabric-sdk-php without Composer
On this page you can find all versions of the php package hiroshiaki/datafabric-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hiroshiaki/datafabric-sdk-php
More information about hiroshiaki/datafabric-sdk-php
Files in hiroshiaki/datafabric-sdk-php
Package datafabric-sdk-php
Short Description Official PHP SDK for DataFabric API - KYC verification, maps, routing, and more
License MIT
Homepage https://datafabric.hiroshiaki.com
Informations about the package datafabric-sdk-php
DataFabric PHP SDK
Official PHP SDK for the DataFabric API. Integrate KYC verification, maps, routing, and more into your PHP applications.
Features
- ✨ AI-Powered OCR - Automatic document data extraction using GPT-4o Vision, Gemini 2.0 Flash, and Claude 3 Opus
- KYC Verification - Identity verification and document checks with risk scoring
- Document Upload - Upload ID cards, passports, driver's licenses with image validation
- Easy Integration - Simple, intuitive API with strongly-typed responses
- PSR-4 Autoloading - Modern PHP standards
- Fully Typed - PHP 8.0+ with strict type declarations
- Test & Live Modes - Separate environments for development and production
- Comprehensive Error Handling - Custom exceptions with detailed messages
- Webhook Support - Real-time notifications for async processing
Requirements
- PHP 8.0 or higher
- Composer
- ext-json (typically included with PHP)
- GuzzleHTTP 7.0 or higher
Installation
Install via Composer:
Quick Start
Configuration
API Keys
Get your API keys from the DataFabric Dashboard:
- Test keys:
dfb_test_*- Use for development and testing (no charges) - Live keys:
dfb_live_*- Use for production
Custom Configuration
Usage
Create KYC Check
Create a new identity verification check:
Required Fields
first_name- First namelast_name- Last namedate_of_birth- Date of birth (YYYY-MM-DD format)document_type- One of:passport,drivers_license,national_id,residence_permitdocument_number- Document number
Get Check Status
Retrieve the status of an existing check:
Status Values
pending- Check is queuedin_progress- Currently processingcompleted- Processing finishedfailed- Processing failed (can be reprocessed)
Result Values (when completed)
approved- Identity verified, low riskrejected- Failed verificationreview_required- Manual review needed
Risk Scores
low- All checks passedmedium- Minor issues detectedhigh- Significant risk factors
List Checks
List checks with optional filtering:
Reprocess Failed Check
Retry a failed check:
Upload Documents with AI OCR
Upload ID cards, passports, or driver's licenses with automatic data extraction:
Supported Image Types
front- Front of document (ID card, passport, driver's license)back- Back of documentselfie- Selfie photo for facial verificationproof_of_address- Utility bill, bank statement, etc.
Image Requirements
- Formats: JPEG, PNG, WebP
- Max Size: 10MB
- Recommended: Minimum 1000px width for best OCR accuracy
- Quality: Clear, well-lit, no glare or shadows
AI-Extracted Fields
The OCR system can extract:
- Document type (passport, national_id, drivers_license)
- Full name, first name, last name
- ID/Document number
- Date of birth
- Gender
- Nationality
- Address
- Confidence score (0-100)
Supported Documents
- Malaysian IC (MyKad)
- Passports
- Driver's Licenses
- National IDs
- Residence Permits
AI Models Used
- Google Gemini 2.0 Flash
- GPT-4o Vision
- Claude 3 Opus
Processing time: 2-5 seconds per document
Get All Documents
Retrieve all uploaded documents for a check:
Response Objects
KycCheckResponse
Single check response with helper methods:
KycCheckListResponse
Paginated list of checks:
KycDocumentResponse
Document upload response with AI OCR data:
KycDocumentListResponse
List of documents for a check:
Error Handling
All SDK methods throw KycException on errors:
Common Error Scenarios
- Invalid API key → Authentication error
- Missing required fields → Validation error
- Rate limit exceeded → Rate limit error
- Network issues → Connection error
Testing
Run the test suite:
Run tests with coverage:
Run static analysis:
Check code style:
Fix code style:
Examples
See the examples/ directory for complete examples:
Best Practices
-
Use Test Keys in Development
- Always use
dfb_test_keys during development - Switch to
dfb_live_keys only in production
- Always use
-
Store API Keys Securely
- Never commit API keys to version control
- Use environment variables or secure vaults
- Rotate keys periodically
-
Handle Errors Gracefully
- Always wrap API calls in try-catch blocks
- Log errors for debugging
- Provide user-friendly error messages
-
Use Webhooks
- Don't poll for status updates
- Set up webhook endpoints for async notifications
- Verify webhook signatures (HMAC-SHA256)
-
Validate Before Sending
- Validate data client-side to reduce API calls
- Check required fields before submission
- Format dates correctly (YYYY-MM-DD)
-
Document Upload Best Practices
- Upload high-quality images (min 1000px width)
- Ensure documents are clearly visible and well-lit
- Avoid glare, shadows, or obstructions
- Use appropriate image types (front, back, selfie, proof_of_address)
- Keep file sizes under 10MB
- Use JPEG, PNG, or WebP formats
-
OCR Data Usage
- Always check
hasOcrData()before accessing extracted fields - Verify OCR confidence scores (aim for >90%)
- Manually review cases with low confidence
- Compare extracted data with user-submitted data
- Handle null values gracefully
- Always check
-
Monitor API Usage
- Track request IDs for debugging
- Monitor rate limits (10-120 req/min depending on plan)
- Log all API interactions
- Watch for expiration dates on checks (30 days)
- Keep SDK Updated
- Regularly update to the latest version
- Review changelogs for breaking changes
- Test updates in a staging environment
Environment Variables
Store your API key in environment variables:
CI/CD & Automated Releases
This package uses GitLab CI/CD for automated testing and releases. See docs/GITLAB_CI.md for complete setup instructions.
Automatic versioning based on commit messages:
The pipeline automatically:
- Tests all code (PHPStan, PSR-12, PHPUnit)
- Creates version tags
- Publishes to Packagist
Framework Integration
Laravel
Create a service provider:
Symfony
Define as a service:
Documentation
- Getting Started Guide - Comprehensive beginner's guide with framework integration
- API Documentation - Official DataFabric API documentation
- Examples Directory - Working code examples for all features
Support
- Documentation: https://datafabric.hiroshiaki.com/docs
- Issues: GitLab Issues
- Email: [email protected]
Changelog
See CHANGELOG.md for version history.
Contributing
See CONTRIBUTING.md for contribution guidelines.
License
This SDK is licensed under the MIT License. See LICENSE for details.
Credits
Developed and maintained by Hiroshi Aki.
DataFabric - API-first data services for modern applications.
Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
Contributing
Contributions are welcome! This project uses automated testing and semantic versioning:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and ensure tests pass:
composer test - Use semantic commit messages:
fix:for bug fixes (patch version)feat:for new features (minor version)breaking:for breaking changes (major version)
- Push to your fork and submit a pull request
Development Setup
See docs/GITLAB_CI.md for CI/CD details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: docs/
- Issues: GitLab Issues
- API Documentation: https://datafabric.hiroshiaki.com/docs
Project Status
Active development. Automated releases via GitLab CI/CD.