1

symfony 2、composer、sass フレームワークを使用しています

MYBundle/Resources/public/ の下に files/ および images/ という追加のフォルダーがあります。

コマンドを実行すると、何らかの理由でこのファイルまたは画像フォルダーが web/ の下に作成されません。

php アプリ/コンソール アセット:インストール

ただし、web/bundles/mybundle/files の下に作成します。

画像フォルダーと同じ: web/bundles/mybundle/images..

私はこれらのフォルダしか持っていません..ウェブの下に..

web/ 
  bundles/
  css/ 
  js/

画像とファイルフォルダーである web/ の下にある他の2つのフォルダーを取得する方法...

このような..

web/ 

 bundles/ 
 images/ 
 css/ 
 js/ 
 files/

files/ フォルダーに termsandconditions.pdf のようなファイルを保持する必要があるためです。

config.yml の私の構成は次のとおりです。

# Assetic Configuration

parameters:
    # Assetic
    assetic.filter.compass.images_dir: %kernel.root_dir%/../web/images
    assetic.filter.compass.http_path:  /images
    assetic.filter.compass.images_dir: %kernel.root_dir%/../web/files
    assetic.filter.compass.http_path:  /files

assetic:
    debug:          %kernel.debug%
    use_controller: false
    filters:
        sass:    ~
        compass: ~
        cssrewrite: ~

小枝ファイルのパスは次のとおりです。

<div class="small-4 columns">
                <p>I accept the <a href="{{ asset('/files/terms_and_conditions.pdf') }}" target="_blank"><span class="pinkText">Terms and Conditions</span></a></p>
            </div>

誰か手順を教えてください...私はSymfonyに精通しています

4

2 に答える 2

0

あなたの特定のケースでは、terms_and_conditions.pdf を web/ フォルダー内に手動で配置することをお勧めします。そのケースを解決するために bundle/app/assetic を使用する必要はありません。また、そのためにコントローラーを使用する必要もありません。

于 2016-01-12T14:27:36.817 に答える
0

Everything in your public folder is being copied to web folder when you install the assets.

So create a folder file and then call them like these:

<p>I accept the <a href="{{ asset('bundles/bundleName/files/terms_and_conditions.pdf') }}">

or use a controller to server it

use Symfony\Component\HttpFoundation\BinaryFileResponse;



Class Controller ....
    function downloadTermsAndCondsAction() {

    $file = __DIR__.'/../../../../web/bundles/bundleName/files/terms_and_conditions.pdf';
    $response = new BinaryFileResponse($file);
    return $response;
}
于 2013-10-21T10:29:30.147 に答える