tourze / wechat-mini-program-short-link-bundle
小程序 Short Link
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/wechat-mini-program-short-link-bundle
Requires
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- symfony/config: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/security-http: ^7.3
- symfony/yaml: ^7.3
- tourze/bundle-dependency: 1.*
- tourze/symfony-dependency-service-loader: 1.0.*
- tourze/wechat-mini-program-bundle: 1.0.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- tourze/http-client-bundle: 1.1.*
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
This package is auto-updated.
Last update: 2025-11-14 09:36:00 UTC
README
A Symfony bundle for generating WeChat Mini Program short links.
Features
- Generate temporary or permanent short links for WeChat Mini Programs
- Symfony integration with dependency injection
- Comprehensive test coverage
- PSR-4 autoloading support
- Simple and intuitive API
Installation
composer require tourze/wechat-mini-program-short-link-bundle
Quick Start
Basic Usage
<?php use WechatMiniProgramBundle\Entity\Account; use WechatMiniProgramShortLinkBundle\Request\ShortLinkRequest; // Create a WeChat Mini Program account $account = new Account(); $account->setAppId('your_app_id'); $account->setAppSecret('your_app_secret'); // Create short link request $request = new ShortLinkRequest(); $request->setAccount($account); $request->setPageUrl('pages/index/index'); $request->setPageTitle('Home Page'); $request->setPermanent(false); // false for temporary, true for permanent // Get request options for API call $options = $request->getRequestOptions(); $path = $request->getRequestPath(); // '/wxa/genwxashortlink'
Configuration
This bundle requires the tourze/wechat-mini-program-bundle package and uses its account configuration.
Request Parameters
pageUrl(string): The page URL within the mini programpageTitle(string): The title for the short linkpermanent(bool): Whether the short link is permanent (default: false)
API Endpoint
The bundle generates requests for the WeChat API endpoint /wxa/genwxashortlink.
Advanced Usage
Custom Configuration
This bundle integrates with tourze/wechat-mini-program-bundle for account management.
Ensure you have properly configured your WeChat Mini Program accounts.
Error Handling
<?php use WechatMiniProgramShortLinkBundle\Request\ShortLinkRequest; try { $request = new ShortLinkRequest(); $request->setAccount($account); $request->setPageUrl('pages/products/detail?id=123'); $request->setPageTitle('Product Detail'); $options = $request->getRequestOptions(); // Handle API call with proper error handling } catch (\Exception $e) { // Handle errors appropriately }
Best Practices
- Use meaningful page titles that describe the destination
- Consider using permanent links sparingly as they cannot be deleted
- Validate page URLs before creating short links
- Implement proper error handling for API failures
Security
When using this bundle, please consider the following security aspects:
- Input Validation: Always validate and sanitize page URLs and titles before creating short links
- Access Control: Implement proper authorization checks before allowing short link creation
- Rate Limiting: Consider implementing rate limiting to prevent abuse of the short link generation API
- Audit Logging: Log short link creation activities for security monitoring
Requirements
- PHP 8.1+
- Symfony 6.4+
- tourze/wechat-mini-program-bundle
License
This bundle is released under the MIT License. See the bundled LICENSE file for details.