caxy/xdomain-bundle

为IE9提供跨域请求支持的XDomain

1.0.2 2016-07-12 01:47 UTC

This package is auto-updated.

Last update: 2024-09-22 07:22:51 UTC


README

使用此包以支持无CORS的跨域XHR。它依赖于XDomain JavaScript库。

安装

在您的composer.json中需要caxy/xdomain-bundle包,并更新您的依赖。

$ composer require caxy/xdomain-bundle

app/AppKernel.php中注册该包

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Caxy\Bundle\XDomainBundle\CaxyXDomainBundle(),
    );
}

routing.yml中导入路由定义

# app/config/routing.yml
caxy_xdomain:
    resource: "@CaxyXDomainBundle/Resources/config/routing.yml"

app/config/config.yml中启用包的配置

# app/config/config.yml
caxy_xdomain:
    allow_from: http://example.com

将名为xdomain_js的资产添加到您的Assetic包配置中,并指定XDomain脚本的URL。此示例中的URL来自XDomain文档

# app/config/config.yml
framework:
    assets:
        packages:
            xdomain:
                version: 0.7.5
                version_format: %%2$s/dist/%%1$s
                base_urls:
                    - //cdn.rawgit.com/jpillora/xdomain