aspose / barcode
Aspose.BarCode for PHP via Java is a robust barcode generation and recognition component.
Installs: 2 626
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 8
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- ext-gd: *
- apache/thrift: ^0.20.0
- dev-master
- 25.5.6
- 25.5.5
- v25.5
- v25.4
- 25.3
- 25.2.0
- 25.1.0
- 24.12.0
- 24.11.0
- 24.10.0
- v24.9.0
- 24.8
- 24.7.1
- 24.7
- 24.6
- 24.5
- 24.4
- 24.3
- 24.2.1
- 24.2.0
- 24.1.0
- 23.12.0
- 23.11.0
- 23.10.0
- 23.9.0
- 23.8.0
- 23.7.0
- 23.6.0
- 23.5.0
- 23.4.0
- 23.3.0
- 23.2.0
- 23.1.0
- 22.12.1
- 22.11.0
- 22.10.1
- 22.10.0
- 22.9.0
- 22.8.0
- 22.6.0
- 22.5.1
- 22.4.0
- 22.3.0
- 22.2.0
- 22.1.0
- 21.12.0
- 21.11.0
- 21.10.0
- 21.9.0
- 21.8.0
- 21.7.0
- 21.6.0
- 21.5.1
- 21.5.0
- 21.4.0
- 21.3.0
- 21.2.0
- 21.1.0
- 20.12.0
- 20.11.1
- 20.9.3
- 20.8.0
- 20.7.0
- 20.6.0
This package is auto-updated.
Last update: 2025-06-14 17:05:28 UTC
README
Aspose.BarCode for PHP via Java is a robust and reliable barcode generation and recognition component, written in PHP and Java. It allows developers to quickly and easily add barcode creation and scanning functionality to their PHP applications.
General Barcode Features
- Supports most established barcode standards and barcode specifications.
- Ability to read & export barcodes in multiple image formats including BMP, GIF, JPEG & PNG.
- Provides full control over barcode images including background color, bar color, image quality, rotation angle, x-dimension, resolution and more.
- Complete control over barcode captions including caption font, back color, fore color, alignment, and location.
- Support for checksum.
- Support for X-dimension & Y-dimension for 2D BarCodes.
- Support for Wide to Narrow Ratio for supported symbologies.
- Support for DataMatrix barcode with X12, EDIFACT & Base 256 encoding.
Barcode Recognition Features
- Can read most common 1D, 2D barcodes anywhere at any angle from an image.
- Specify an area in the image to scan the barcode
- Get region information for the barcodes recognized in the image
Barcode Imaging Features
- Manipulate the barcodes image borders, border color, style, margins, width, etc.
- Rotate barcode images to any degree.
- Set anti-aliasing for barcode images.
- Manage barcode image margins.
- Customize image resolution.
- Set size in inches or millimeters.
- Auto size barcode images.
Barcode Symbologies
Numeric Only: EAN13, EAN8, UPCA, UPCE, ISBN, ISMN, ISSN, Interleaved2of5, Standard2of5, MSI, Code11, Codabar, Postnet, Planet, EAN14(SCC14), SSCC18, ITF14, IATA 2 of 5, DatabarOmniDirectional, DatabarStackedOmniDirectional, DatabarExpandedStacked, DatabarStacked, DatabarLimited, DatabarTruncated
Alpha-Numeric: GS1Code128, Code128, Code39 Extended, Code39 Standard, Code93 Extended, Code93 Standard, Australia Post, Italian Post 25, Matrix 2 of 5, DatabarExpanded, PatchCode
2D Symbologies: PDF417, DataMatrix, Aztec, QR, MicroQR, GS1DataMatrix, Code16K, CompactPDF417, Swiss QR (QR Bill)
Read Barcodes From
Images: BMP, GIF, JPEG, PNG, TIFF, TIFF_IN_CMYK, EMF, SVG, PDF
Export Barcode Labels As Images
Images: BMP, GIF, JPEG, PNG, TIFF, TIFF_IN_CMYK, EMF, SVG, PDF
Get Started with Aspose.BarCode for PHP via Java
Aspose.BarCode for PHP via Java is distributed uses a background Java server (via Apache Thrift) to bridge PHP and Java functionality.
Requirements
-Java 1.8 or higher -PHP 7.4 or higher -Composer
Installation Steps
-
Install the package via Composer:
composer require aspose/barcode
-
In the root of the package, locate and run the
start_server.cmd
file to start the background Thrift server:start_server.cmd
You can also embed a similar script into your own project:
Windows:
@echo off :: Get the directory where this script is located set SCRIPT_DIR=%~dp0 :: Define the path to the JAR file relative to this script set JAR_PATH=%SCRIPT_DIR%vendor\aspose\barcode-php\lib\aspose-barcode-php-thrift-25.5.jar :: Define the log file path (optional) set LOG_FILE=%SCRIPT_DIR%server.log echo Starting Thrift server... start /B java -jar "%JAR_PATH%" echo Thrift server started! Logs are in %LOG_FILE%. exit
Linux and macOS:
#!/bin/bash # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Define the path to the JAR file relative to this script JAR_PATH="$SCRIPT_DIR/vendor/aspose/barcode-php/lib/aspose-barcode-php-thrift-25.5.jar" # Define the log file path (optional) LOG_FILE="$SCRIPT_DIR/server.log" echo "Starting Thrift server..." nohup java -jar "$JAR_PATH" > "$LOG_FILE" 2>&1 & echo "Thrift server started! Logs are in $LOG_FILE."
This script launches a Java process using the JAR file:
vendor/aspose/barcode-php/lib/aspose-barcode-php-thrift-25.5.jar
Make sure the server is running by checking the console output or verifying that port 9090 is open (e.g., usingnetstat
). -
Once the Thrift server is running, your PHP application can interact with the Java-based barcode engine
using the public API classes defined in theAspose\Barcode
namespace.
These classes act as PHP client wrappers, communicating with the backend over Apache Thrift.
You can use them to generate and recognize barcodes by simply calling methods as if they were native PHP objects, while the actual processing is performed on the Java side.
Sample code snippet for barcode recognition:
The example below shows how to initialize the barcode reader, apply a license, set checksum validation, and read barcodes from a sample image:
public function barcodeReaderExample() { $license = new License(); $license->setLicense(TestsAssist::PHP_LICENSE_PATH); $image_path = TestsAssist::TESTDATA_ROOT . "Recognition/1D/Code39/code39.gif"; $reader = new BarCodeReader($image_path, null, null); $reader->getBarcodeSettings()->setChecksumValidation(ChecksumValidation::ON); $foundBarCodes = $reader->readBarCodes(); $foundCount = $reader->getFoundCount(); print("Count of found barcodes: ". $foundCount.PHP_EOL); print("CodeText " . $foundBarCodes[0]->getCodeText().PHP_EOL); print("CodeType " . $foundBarCodes[0]->getCodeType().PHP_EOL); print("CodeType " . $foundBarCodes[0]->getCodeTypeName().PHP_EOL); }
Sample code snippet for barcode reading and generation:
The example below shows how to initialize the barcode generator, apply a license, generate barcode and read barcode:
public function readAndGenerateExample() { $license = new License(); $license->setLicense(TestsAssist::PHP_LICENSE_PATH); $codeText = "12345678"; $encodeType = EncodeTypes::CODE_11; $generator = new BarcodeGenerator($encodeType, $codeText); $base64Image = $generator->generateBarCodeImage(BarCodeImageFormat::PNG); $reader = new BarCodeReader($base64Image, null, null); $resultsArray = $reader->readBarCodes(); $barCodeResult = $resultsArray[0]; $codeText = $barCodeResult->getCodeText(); $codeType = $barCodeResult->getCodeTypeName(); print("codeText " . $codeText); print("codeType " . $codeType); }
Comprehensive instructions can be found in the official documentation.
Product | Documentation | Blog | API Reference | Search | Free Support | Temporary License