{"id":36994460,"url":"https://github.com/nkamuo/barcode-bundle","last_synced_at":"2026-01-13T23:46:41.020Z","repository":{"id":287727427,"uuid":"964870435","full_name":"nkamuo/barcode-bundle","owner":"nkamuo","description":"A flexible and extensible library for generating, processing, encoding, decoding, and formatting barcodes, DataMatrix and QR codes","archived":false,"fork":false,"pushed_at":"2025-09-15T19:47:13.000Z","size":1765,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T11:57:43.127Z","etag":null,"topics":["barcode","barcode-generator","gs1","qrcode","qrcode-generator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nkamuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-11T23:51:33.000Z","updated_at":"2025-09-11T07:01:04.000Z","dependencies_parsed_at":"2025-05-19T00:19:44.092Z","dependency_job_id":"3894b3b8-f864-4140-a140-54362849c926","html_url":"https://github.com/nkamuo/barcode-bundle","commit_stats":null,"previous_names":["nkamuo/barcode-bundle"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nkamuo/barcode-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkamuo%2Fbarcode-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkamuo%2Fbarcode-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkamuo%2Fbarcode-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkamuo%2Fbarcode-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nkamuo","download_url":"https://codeload.github.com/nkamuo/barcode-bundle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkamuo%2Fbarcode-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","barcode-generator","gs1","qrcode","qrcode-generator"],"created_at":"2026-01-13T23:46:40.913Z","updated_at":"2026-01-13T23:46:41.010Z","avatar_url":"https://github.com/nkamuo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Barcode Bundle for Symfony and Standalone Applications\n\nThe **Barcode Bundle** is a flexible and extensible library for generating, processing, encoding, decoding, and formatting barcodes, DataMatrix and QR codes. It is designed to work seamlessly with Symfony applications but can also be used in standalone PHP projects. The library aims to support established standards such as `GS1` and `ANSI` — either out of the box or through third-party and custom extensions.\n\n---\n\n## Table of Contents\n\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [Quick Start](#quick-start)\n    - [Using in Symfony](#using-in-symfony)\n    - [Using in Standalone PHP Applications](#using-in-standalone-php-applications)\n4. [Configuration](#configuration)\n    - [Symfony Configuration](#symfony-configuration)\n    - [Standalone Configuration](#standalone-configuration)\n5. [Components Overview](#components-overview)\n    - [Encoders](#encoders)\n    - [Decoders](#decoders)\n    - [Formatters](#formatters)\n    - [Generators](#generators)\n    - [Repositories](#repositories)\n    - [Processors](#processors)\n6. [Extending the Library](#extending-the-library)\n7. [Customization](#customization)\n8. [Examples](#examples)\n9. [Testing](#testing)\n10. [Contributing](#contributing)\n11. [Credits](#credits)\n12. [License](#license)\n\n---\n\n## 1. Introduction\n\nThe Barcode Bundle provides a complete solution for working with barcodes and QR codes. It supports:\n- Generating barcodes and QR codes.\n- Encoding data into various formats.\n- Decoding barcodes and QR codes into structured data.\n- Formatting barcodes for human-readable or standard-compliant outputs.\n- Extending and customizing components like formatters, encoders, decoders, and processors.\n\nWhether you're building a Symfony application or a standalone PHP project, this library is designed to be modular, extensible, and easy to use.\n\n---\n\n## 2. Installation\n\n### Requirements\n- PHP 8.1 or higher.\n- Symfony 6.0 or later (for Symfony integration).\n- Composer 2.0 or later.\n\n### Install via Composer\n\nTo install the library, run:\n\n```bash\ncomposer require nkamuo/barcode-bundle:dev-main\n```\n\nFor Symfony applications, this will:\n- Register the `Nkamuo\\Barcode\\BarcodeBundle` in `config/bundles.php`.\n- Copy the default configuration to `config/packages/barcode.yaml`.\n\nIf the bundle is not automatically registered, add it manually:\n\n```php\n// config/bundles.php\nreturn [\n    // ...\n    Nkamuo\\Barcode\\BarcodeBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n---\n\n## 3. Quick Start\n\n### Using in Symfony\n\n1. **Install the library** (see [Installation](#installation)).\n2. **Configure the bundle** in `config/packages/barcode.yaml` (see [Symfony Configuration](#symfony-configuration)).\n3. **Use the Barcode Processor**:\n\n```php\nuse Nkamuo\\Barcode\\BarcodeProcessorInterface;\n\n/** @var BarcodeProcessorInterface $processor */\n$processor = $container-\u003eget(BarcodeProcessorInterface::class);\n\n// Generate a barcode for Raw-Material\n$barcode = $processor-\u003egenerate([\n    'prefix' =\u003e 'RM-',\n    'standard' =\u003e 'CUSTOM'\n    ]);\necho $barcode-\u003egetValue(); // Outputs: RM-00000001\n\n// Encode the barcode into a QR code\n$encoded = $processor-\u003eencode($barcode, 'QR', 'PNG');\nfile_put_contents('barcode.png', $encoded);\n\n// Decode a barcode\n$decodedBarcode = $processor-\u003edecode('0101234567890128', 'EAN-13');\necho $decodedBarcode-\u003egetValue(); // Outputs: 0101234567890128\n```\n\n### Using in Standalone PHP Applications\n\n1. **Install the library** (see [Installation](#installation)).\n2. **Set up the components manually**:\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Nkamuo\\Barcode\\BarcodeProcessor;\nuse Nkamuo\\Barcode\\Factory\\BarcodeFactory;\nuse Nkamuo\\Barcode\\Repository\\InMemoryBarcodeRepository;\nuse Nkamuo\\Barcode\\Formatter\\ChainBarcodeFormatter;\nuse Nkamuo\\Barcode\\Encoder\\ChainBarcodeEncoder;\nuse Nkamuo\\Barcode\\Decoder\\ChainBarcodeDecoder;\nuse Nkamuo\\Barcode\\Generator\\ChainBarcodeGenerator;\n\n// Initialize components\n$factory = new BarcodeFactory();\n$repository = new InMemoryBarcodeRepository();\n$formatter = new ChainBarcodeFormatter([...]); // Add formatters\n$encoder = new ChainBarcodeEncoder([...]);     // Add encoders\n$decoder = new ChainBarcodeDecoder([...]);     // Add decoders\n$generator = new ChainBarcodeGenerator([...]); // Add generators\n\n// Create the processor\n$processor = new BarcodeProcessor(\n    factory: $factory,\n    encoder: $encoder,\n    decoder: $decoder,\n    generator: $generator,\n    formatter: $formatter,\n    repository: $repository\n);\n\n// Use the processor\n$barcode = $processor-\u003egenerate([\n    'prefix' =\u003e 'FXT',\n    'pad_lenth' =\u003e 5,\n    ]);\necho $barcode-\u003egetValue(); // Output: FXT0000012\n```\n\n---\n\n## 4. Configuration\n\n### Symfony Configuration\n\nThe default configuration file is located at `config/packages/barcode.yaml`. You can customize the following settings:\n\n```yaml\nbarcode:\n    default_storage: 'in_memory'             # Default storage for barcodes\n    enabled_formatters: ['qrcode', 'barcode'] # List of formatters to enable\n    processors:\n        default:                              # Default processor chain\n            encoders: ['basic_encoder']\n            decoders: ['default_decoder']\n            formatters: ['default_formatter']\n```\n\n### Standalone Configuration\n\nFor standalone applications, you can configure components manually by instantiating them and passing the required dependencies (see [Quick Start](#using-in-standalone-php-applications)).\n\n---\n\n## 5. Components Overview\n\n### [Encoders](docs/encoder.md)\nEncoders convert `BarcodeInterface` instances into specific formats like QR codes, Data Matrix, or PNG images.  \nSee the [Encoders Documentation](docs/encoder.md) for more details.\n\n### [Decoders](docs/decoder.md)\nDecoders interpret raw barcode data and convert it into structured `BarcodeInterface` instances.  \nSee the [Decoders Documentation](docs/decoder.md) for more details.\n\n### [Formatters](docs/formatter.md)\nFormatters provide a way to format barcode data into human-readable or standard-compliant strings.  \nSee the [Formatters Documentation](docs/formatter.md) for more details.\n\n### [Generators](docs/generator.md)\nGenerators create new barcodes based on specific contexts or configurations.  \nSee the [Generators Documentation](docs/generator.md) for more details.\n\n### [Repositories](docs/repository.md)\nRepositories manage the persistence and retrieval of barcodes.  \nSee the [Repositories Documentation](docs/repository.md) for more details.\n\n### [Processors](docs/processor.md)\nProcessors orchestrate the interaction between all components, providing a unified interface for barcode operations.  \nSee the [Processors Documentation](docs/processor.md) for more details.\n\n---\n\n## 6. Extending the Library\n\nThe library is designed to be extensible. You can add custom formatters, encoders, decoders, and processors by implementing the respective interfaces.  \nRefer to the [Extending Documentation](docs) for detailed guides on how to extend each component.\n\n---\n\n## 7. Customization\n\nYou can customize the library by:\n- Adding custom formatters, encoders, decoders, or generators.\n- Creating custom processors to handle specific workflows.\n- Implementing your own repository for barcode storage (e.g., database-backed).\n\n---\n\n## 8. Examples\n\n### Generate and Encode a Barcode\n\n```php\n$barcode = $processor-\u003egenerate(['type' =\u003e 'GTIN', 'value' =\u003e '0123456789012']);\n$encoded = $processor-\u003eencode($barcode, 'QR', 'PNG');\nfile_put_contents('barcode.png', $encoded);\n```\n\n### Decode a Barcode\n\n```php\n$decodedBarcode = $processor-\u003edecode(\n    data: ']d201034531200000111719112510ABCD1234',\n    symbol: null, //DataMatrix\n    format: null,\n    context: ['standard' =\u003e 'GS1']\n);\necho $barcode-\u003egetAttribute('01');// Output: 03453120000011 [GTIN]\necho $barcode-\u003egetAttribute('10');// Output:  ABCD1234 [Batch Number]\necho $barcode-\u003egetAttribute('17');// Output:  191125 [Expiry Date]\n```\n\n### Format a Barcode\n\n```php\n$formatted = $formatter-\u003eformat($barcode, 'LABEL');\necho $formatted;\n```\n\n---\n\n## 9. Testing\n\nRun the tests using PHPUnit:\n\n```bash\ncomposer install\nvendor/bin/phpunit tests/simple\n```\n\n---\n\n## 10. Contributing\n\nContributions are welcome! Please follow these steps:\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Write tests for your changes.\n4. Open a pull request.\n\nFeel free to open issues for bugs or feature requests.\n\n---\n\n## 11. Credits\n\nThis library leverages the following third-party libraries:\n- [chillerlan/php-qrcode](https://github.com/chillerlan/php-qrcode)\n- [picqer/php-barcode-generator](https://github.com/picqer/php-barcode-generator)\n- [endroid/qr-code](https://github.com/endroid/qr-code)\n\n---\n\n## 12. License\n\nThis library is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.\n\n---\n\nEnjoy using the Barcode Bundle! 😊","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkamuo%2Fbarcode-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnkamuo%2Fbarcode-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkamuo%2Fbarcode-bundle/lists"}