survos/barcode-bundle
Composer 安装命令:
composer require survos/barcode-bundle
包简介
Integrates picqer/php-barcode-generator in a Symfony application
README 文档
README
Symfony Bundle for the picqer/php-barcode-generator library, to generate an SVG barcode within twig.
Barcode Bundle Demo
Quick demonstration of survos/barcode-bundle functionality.
Prerequisites
- PHP 8.2+
- Symfony CLI
- Castor task runner
Install Castor
curl "https://castor.jolicode.com/install" | bash
Quick Start
# Create a new Symfony project symfony new barcode-demo --webapp cd barcode-demo # Download the demo castor file wget https://raw.githubusercontent.com/survos/barcode-bundle/main/castor/castor.php # See available tasks castor list # Build complete demo (installs bundle, creates files, sets up database, starts server) castor build
Individual Steps
Run these independently if you prefer:
castor setup # Install bundle and create directories castor copy-files # Copy demo files from bundle castor database # Configure SQLite and create schema castor import # Load sample product data castor open # Start web server and open browser castor clean # Remove demo files (optional)
What Gets Created
src/Entity/Product.php- Sample entity with barcode supportsrc/Repository/ProductRepository.php- Repositorysrc/Command/ImportProductsCommand.php- Data import commandtemplates/products.html.twig- Product listing template- SQLite database with sample products
Next Steps
Visit the opened browser to see:
- Product listing with barcodes
- EasyAdmin dashboard
- Barcode generation examples
Cleanup
castor clean # Removes all demo files
Troubleshothy
Castor file not found: Make sure you're in the project root directory
Permission denied: Run chmod +x castor.php
Bundle not installed: Run castor setup first before other commands
Demo Application
Try the bundle instantly:
symfony new barcode-demo --webapp && cd barcode-demo && \ wget https://raw.githubusercontent.com/survos/barcode-bundle/main/castor/castor.php && \ castor build
See the demo README for step-by-step instructions.
composer req survos/barcode-bundle
{# as a filter #} {{ '12345'|barcode }} {# as a function #} {{ barcode(random(), 2, 80, 'red' }}
To set default values (@todo: install recipe)
# config/packages/barcode.yaml barcode: widthFactor: 3 height: 120 foregroundColor: 'purple'
Proof that it works
Requirements:
- Locally installed PHP 8, with GD or Imagick
- Symfony CLI
- sed (to change /app to / without opening an editor)
symfony new BarcodeDemo --webapp && cd BarcodeDemo symfony composer req survos/barcode-bundle symfony console make:controller AppController sed -i "s|/app|/|" src/Controller/AppController.php cat <<'EOF' > templates/app/index.html.twig {% extends 'base.html.twig' %} {% block body %} {{ 'test'|barcode }} or {{ barcode('test', 2, 80, 'red') }} {% endblock %} EOF #echo "{{ 'test'|barcode }} or {{ barcode('test', 2, 80, 'red') }} " >> templates/app/index.html.twig symfony server:start -d symfony open:local
survos/barcode-bundle 适用场景与选型建议
survos/barcode-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.25k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 survos/barcode-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 survos/barcode-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-26