tourze / freight-template-bundle
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/freight-template-bundle
Requires
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- symfony/config: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/form: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/serializer: ^7.3
- symfony/validator: ^7.3
- symfony/yaml: ^7.3
- tourze/arrayable: 1.*
- tourze/bundle-dependency: 1.*
- tourze/doctrine-helper: 1.0.*
- tourze/doctrine-precision-bundle: 1.1.*
- tourze/doctrine-snowflake-bundle: 1.1.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/doctrine-track-bundle: 1.1.*
- tourze/doctrine-user-bundle: 1.0.*
- tourze/easy-admin-enum-field-bundle: 1.0.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/product-core-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2025-11-14 14:29:43 UTC
README
A Symfony bundle for managing freight templates in e-commerce applications. This bundle provides a complete solution for handling shipping cost calculations and template management.
Features
- Freight template management with validation
- Multiple delivery types and valuation methods
- EasyAdmin integration for backend management
- Doctrine ORM integration with proper entity mapping
- RESTful API support
- Comprehensive validation and constraints
- Fixtures for development testing
Requirements
- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM
- EasyAdmin Bundle
Installation
Install the bundle
composer require tourze/freight-template-bundle
Register the bundle
The bundle should be automatically registered by Symfony Flex. If not, add it to config/bundles.php:
return [ // ... Tourze\FreightTemplateBundle\FreightTemplateBundle::class => ['all' => true], ];
Run database migrations
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Load demo fixtures (optional)
php bin/console doctrine:fixtures:load --append --group=FreightTemplate
Usage
Service Usage
use Tourze\FreightTemplateBundle\Service\FreightTemplateService; class YourService { public function __construct( private FreightTemplateService $freightTemplateService ) {} public function calculateShipping(string $templateId): ?FreightTemplate { // Find freight template by ID return $this->freightTemplateService->findValidTemplateById($templateId); } public function getAvailableTemplates(): array { // Get all valid freight templates return $this->freightTemplateService->findAllValidTemplates(); } }
Entity Usage
use Tourze\FreightTemplateBundle\Entity\FreightTemplate; use Tourze\FreightTemplateBundle\Enum\FreightValuationType; use Tourze\ProductCoreBundle\Enum\DeliveryType; $template = new FreightTemplate(); $template->setName('Standard Shipping'); $template->setDeliveryType(DeliveryType::EXPRESS); $template->setValuationType(FreightValuationType::FIXED); $template->setCurrency('CNY'); $template->setFee('15.00'); $template->setValid(true);
API Reference
FreightTemplateService
| Method | Parameters | Return Type | Description |
|---|---|---|---|
findValidTemplateById() |
string $templateId |
?FreightTemplate |
Find valid template by ID |
findAllValidTemplates() |
- | array<FreightTemplate> |
Get all valid templates |
findTemplatesBySpuIds() |
array $spuIds |
array<FreightTemplate> |
Find templates by SPU IDs |
FreightTemplate Entity
Main Properties
id: string - Unique identifier (Snowflake ID)name: string - Template namedeliveryType: DeliveryType - Delivery methodvaluationType: FreightValuationType - Valuation methodcurrency: string - Currency code (default: CNY)fee: string - Shipping feevalid: bool - Whether template is activesortNumber: int - Sort ordercreateTime: DateTime - Creation timestampupdateTime: DateTime - Last update timestamp
Enums
DeliveryType (配送方式)
EXPRESS- Express deliveryPICKUP- Self pickupSTANDARD- Standard deliveryECONOMY- Economy delivery
FreightValuationType (计费方式)
FIXED- Fixed feeBY_ITEM- Per item billing
Admin Interface
Access the freight template management interface at /admin/product/freight-template:
- Create and edit freight templates
- Configure delivery types and valuation methods
- Manage template validity and sorting
- Filter and search templates
Testing
# Run all tests ./vendor/bin/phpunit packages/freight-template-bundle/tests # Run PHPStan analysis php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/freight-template-bundle
Dependencies
tourze/product-core-bundle- Core product functionalitytourze/doctrine-*-bundle- Doctrine integration bundleseasycorp/easyadmin-bundle- Admin interfacetourze/easy-admin-enum-field-bundle- Enum field support for EasyAdmin
Configuration
The bundle works out of the box with minimal configuration. However, you can customize certain aspects:
# config/packages/freight_template.yaml freight_template: default_currency: 'CNY' default_valuation_type: 'fixed'
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
License
MIT License