opale / externaluribundle
构建超出您的 symfony 应用的 Uri
1.1.3
2016-01-14 17:10 UTC
Requires
- php: >=5.4.34
- opale/externalurigenerator: ~0.4
Requires (Dev)
- phpunit/phpunit: ~4.7
This package is not auto-updated.
Last update: 2020-08-03 06:53:24 UTC
README
通过 Composer 安装
composer require opale/externaluribundle
配置
注册该包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Opale\ExternalUriBundle\OpaleExternalUriBundle(), ); // ... }
在配置文件中添加外部路由(例如:externalRouting.yml)
xternal_url_key: scheme: "https" path: /path/{configurationId} host: %acme_example.service_url%
将 externalRouting.yml 添加到 config.yml
# Opale ExternalUriGenerator configuration opale_external_uri: resources: - { resource: %kernel.root_dir%/../src/Acme/MyBundle/Resources/config/externalRouting.yml }
使用方法
TWIG
{{ externalUrl(xternal_url_key, {configurationId: 103}) }} ... or {{ externalUrl(xternal_url_key) }}
服务
调用服务 opale_external_uri.generator
$this->get('opale_external_uri.generator')->generate('xternal_url_key', ['configurationId' => 103]);