babeuloula/cdn-php-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

babeuloula/cdn-php-bundle

最新稳定版本:0.3.3

Composer 安装命令:

composer require babeuloula/cdn-php-bundle

包简介

A proxy between your application and CDN PHP

README 文档

README

A Symfony Bundle for CDN PHP.

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require babeuloula/cdn-php-bundle

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    BaBeuloula\CdnPhpBundle\CdnPhpBundle::class => ['all' => true],
];

Step 3: Configure the Bundle

# config/packages/cdn_php.yaml

cdn_php:
    proxy:
        assets_path: 'mandatory'
        url: 'mandatory'
        check_assets: true # if the bundle needs to check if you have the file on the server before fetch from CDN PHP
        encrypted_parameters: false # if you need to hide the query parameters on your application
    encrypter:
        secret_key: null # Signs URLs generated by cdn_php() / cdn() Twig functions (app → browser).
                         # Used to prevent tampering with query parameters on the public-facing proxy route.
                         # Algorithm: SHA1(query_string + secret_key). Validated by Signer::isValid().
                         # Required when proxy.encrypted_parameters is true.
        cdn_secret_key: null # Signs requests sent by Proxy to the CDN PHP service (app → CDN).
                             # Must match the SIGNATURE_SECRET environment variable set on the CDN PHP instance.
                             # Algorithm: HMAC-SHA256(imageUrl:expires, cdn_secret_key).
                             # Leave null if CDN PHP runs without SIGNATURE_SECRET.
        cdn_expires_ttl: 3600 # Validity duration (in seconds) of CDN request signatures.
                              # Only used when cdn_secret_key is set. Default: 3600 (1 hour).
    twig:
        route_name: 'mandatory' # the route to the controller that displays the assets
        route_parameter: 'mandatory' # the route parameter name

Using a fallback handler

If you don't have access to CDN PHP or if you want to use it on local development, you can set up a fallback handler.

Actually, I only support Intervention Image v3.

Intervention\Image\Drivers\Imagick\Driver: ~

BaBeuloula\CdnPhpBundle\FallbackHandler\InterventionImageFallbackHandler:
    arguments:
        $assetsPath: '_your_path_'
        $driver: '@Intervention\Image\Drivers\Imagick\Driver'
        $cache: '_your_cache_instance_'

BaBeuloula\CdnPhpBundle\FallbackHandler\FallbackHandlerInterface: '@BaBeuloula\CdnPhpBundle\FallbackHandler\InterventionImageFallbackHandler'

Contributing

Build and install dependencies

You can use the existing docker stack with the command make install to build the Dockerfile and install the composer dependencies.

If you want to execute some commands through Docker, just use docker/exec your_command.

Run testing stack

# Run all tests
make check

# Execute PHPCS
make lint

# Execute PHPCS fixer
make fixer

# Execute PHPStan
make analyse

统计信息

  • 总下载量: 81
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固