tourze / youzan-api-bundle
有赞API集成Bundle
Installs: 163
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/youzan-api-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/easy-admin-menu-bundle: 0.1.*
- youzanyun/open-sdk: ^2.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-02 05:49:12 UTC
README
[]
(https://packagist.org/packages/tourze/youzan-api-bundle)
[
]
(https://packagist.org/packages/tourze/youzan-api-bundle)
[
]
(https://packagist.org/packages/tourze/youzan-api-bundle)
[
]
(https://packagist.org/packages/tourze/youzan-api-bundle)
A Symfony bundle for integrating with Youzan API, providing account and shop management capabilities.
Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Configuration
- Entities
- Admin Interface
- Advanced Usage
- Security
- Performance Tips
- Changelog
- Contributing
- License
Features
- Account management for Youzan API credentials
- Shop management with multi-account support
- Client service for easy API access
- EasyAdmin integration for backend management
- Doctrine ORM integration with Snowflake ID support
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher
- youzanyun/open-sdk 2.0 or higher
- EasyAdmin Bundle 4.0 or higher
Installation
composer require tourze/youzan-api-bundle
Quick Start
- Add the bundle to your
bundles.php:
<?php return [ // ... YouzanApiBundle\YouzanApiBundle::class => ['all' => true], ];
- Create and manage Youzan accounts:
<?php use YouzanApiBundle\Service\YouzanClientService; // Inject the service public function __construct( private readonly YouzanClientService $youzanClientService ) { } // Create a new account $account = $this->youzanClientService->createAccount( 'Account Name', 'your_client_id', 'your_client_secret' ); // Get API client $client = $this->youzanClientService->getClient($account); // Or get client by client ID $client = $this->youzanClientService->getClientByClientId('your_client_id');
- Use the client to call Youzan API:
<?php // Use the client to make API calls $response = $client->get('/youzan.shop.get', ['version' => '3.0.0']);
Configuration
The bundle registers services automatically. For production use, configure your environment variables:
# .env YOUZAN_CLIENT_ID=your_client_id YOUZAN_CLIENT_SECRET=your_client_secret
Entities
Account
- Manages Youzan API credentials (Client ID, Client Secret)
- Supports multiple shops per account
Shop
- Represents Youzan shops with KDT ID
- Can be associated with multiple accounts
Admin Interface
The bundle provides EasyAdmin controllers for managing accounts and shops:
- Account management: Create, edit, and delete API accounts
- Shop management: Manage shop information and associations
Advanced Usage
For more advanced scenarios, you can extend the entities or create custom services:
<?php use YouzanApiBundle\Entity\Account; use YouzanApiBundle\Entity\Shop; // Custom account with additional properties class ExtendedAccount extends Account { private string $description; // Additional methods... } // Custom shop repository class CustomShopRepository extends ShopRepository { public function findActiveShops(): array { return $this->createQueryBuilder('s') ->where('s.active = :active') ->setParameter('active', true) ->getQuery() ->getResult(); } }
Security
Reporting Security Issues
If you discover a security vulnerability, please send an email to security@tourze.com. All security vulnerabilities will be promptly addressed.
Security Best Practices
- Store API credentials securely using environment variables
- Use HTTPS for all API communications
- Regularly rotate API credentials
- Implement proper access controls for admin interfaces
Performance Tips
- Cache API responses when possible to reduce API calls
- Use batch operations for multiple API requests
- Implement connection pooling for high-volume scenarios
- Monitor API rate limits and implement backoff strategies
Changelog
Version 1.0.0
- Initial release with basic account and shop management
- EasyAdmin integration for backend management
- Youzan API client service with automatic token handling
Contributing
We welcome contributions! Here's how you can help:
- Report Issues: Use GitHub Issues to report bugs or request features
- Submit Pull Requests: Fork the repository and submit PRs for improvements
- Code Style: Follow PSR-12 coding standards
- Testing: Ensure all tests pass before submitting PRs
Development Setup
# Clone the repository git clone https://github.com/yourorg/php-monorepo.git # Install dependencies composer install # Run tests ./vendor/bin/phpunit packages/youzan-api-bundle/tests # Run code analysis ./vendor/bin/phpstan analyse packages/youzan-api-bundle
License
The MIT License (MIT). Please see License File for more information.