A PHP library for generating QR code data in various formats.
Mini QR is a PHP library that provides utilities for generating properly formatted data for various QR code types. This library handles the data encoding and formatting, which can then be used with any PHP QR code generator library.
- β Data Encoding: Generate properly formatted data for various QR code types
- π§ Email: mailto URIs with subject, body, cc, and bcc
- π Phone: tel URIs for phone numbers
- π¬ SMS: SMSTO format for text messages
- π‘ WiFi: WiFi network configuration strings
- π€ vCard: Contact cards (supports vCard 2.1, 3.0, and 4.0)
- π Location: Geographic coordinates in geo URI format
- π Calendar Events: iCalendar format for events
- π Auto-Detection: Automatically detect and parse data types from QR code strings
- β Zero dependencies for core functionality
- β PHP 7.4+ compatible
- β Comprehensive test suite (25 tests, 89 assertions)
The simplest way to use this library is to copy the entire php/ directory to your project:
# Copy the php directory to your project
cp -r php/ /path/to/your/project/mini-qr/Then include the main file:
<?php
require_once 'mini-qr/src/DataEncoding.php';
use MiniQR\DataEncoding;
// Now you can use all functions
$url = DataEncoding::generateUrlData(['url' => 'example.com']);composer require mini-qr/mini-qr-phpCopy just the src/DataEncoding.php file to your project:
require_once 'path/to/php/src/DataEncoding.php';<?php
use MiniQR\DataEncoding;
// Generate a URL
$url = DataEncoding::generateUrlData(['url' => 'example.com']);
// Output: https://example.com
// Generate an email with subject and body
$email = DataEncoding::generateEmailData([
'address' => 'contact@example.com',
'subject' => 'Hello',
'body' => 'This is a test message'
]);
// Output: mailto:contact@example.com?subject=Hello&body=This%20is%20a%20test%20message
// Generate a phone number
$phone = DataEncoding::generatePhoneData(['phone' => '+1234567890']);
// Output: tel:+1234567890
// Generate WiFi credentials
$wifi = DataEncoding::generateWifiData([
'ssid' => 'MyNetwork',
'encryption' => 'WPA',
'password' => 'mypassword123',
'hidden' => false
]);
// Output: WIFI:T:WPA;S:MyNetwork;P:mypassword123;;
// Generate a vCard (version 3.0 by default)
$vcard = DataEncoding::generateVCardData([
'firstName' => 'John',
'lastName' => 'Doe',
'org' => 'Acme Corp',
'email' => 'john.doe@example.com',
'phoneWork' => '+1234567890'
]);The library can automatically detect and parse QR code data:
// Detect URL
$result = DataEncoding::detectDataType('https://example.com');
// $result = ['type' => 'url', 'parsedData' => ['url' => 'https://example.com']]
// Detect email
$result = DataEncoding::detectDataType('mailto:test@example.com?subject=Hello');
// $result = ['type' => 'email', 'parsedData' => ['address' => 'test@example.com', 'subject' => 'Hello', ...]]
// Detect WiFi
$result = DataEncoding::detectDataType('WIFI:T:WPA;S:MyNet;P:pass123;;');
// $result = ['type' => 'wifi', 'parsedData' => ['ssid' => 'MyNet', 'encryption' => 'wpa', ...]]For complete documentation, examples, and API reference, see:
- PHP Library Documentation - Complete guide with all features and examples
- Standalone Usage Guide - How to use the library in your projects
- Port Summary - Details about the PHP port
| Type | Generator Method | Detection |
|---|---|---|
| Text | generateTextData() |
Default fallback |
| URL | generateUrlData() |
http:// or https:// prefix |
generateEmailData() |
mailto: prefix |
|
| Phone | generatePhoneData() |
tel: prefix |
| SMS | generateSmsData() |
SMSTO: or sms: prefix |
| WiFi | generateWifiData() |
WIFI: prefix |
| vCard | generateVCardData() |
BEGIN:VCARD |
| Location | generateLocationData() |
geo: prefix |
| Event | generateEventData() |
BEGIN:VCALENDAR or BEGIN:VEVENT |
Run the test suite using PHPUnit:
# From the php directory
cd php
# Install dependencies
composer install
# Run tests
composer test
# or
./vendor/bin/phpunitAll tests pass with 100% success rate (25 tests, 89 assertions).
- PHP 7.4 or higher
- No external dependencies required for core functionality
- PHPUnit 9.5+ (for testing only)
php/
βββ .gitignore # Git ignore rules for PHP
βββ README.md # Detailed PHP library documentation
βββ STANDALONE_USAGE.md # Usage guide for standalone projects
βββ PORT_SUMMARY.md # PHP port details
βββ composer.json # Composer configuration
βββ phpunit.xml # PHPUnit configuration
βββ src/
β βββ DataEncoding.php # Main library class
βββ tests/
β βββ DataEncodingTest.php # Complete test suite
βββ examples/
βββ basic_usage.php # Usage examples
Contributions are welcome! Please ensure all tests pass before submitting a pull request.
See CONTRIBUTING.md for guidelines.
GPL-3.0-or-later - See LICENSE file for details.
Please review our Code of Conduct before contributing.
This library provides data encoding utilities for QR code generation. Use it with any PHP QR code generator library to create complete QR codes.