survos/barcode-bundle
最新稳定版本:2.0.96
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
统计信息
- 总下载量: 16.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-26