LiipImagineBundle не работает в производственной среде

Я использую LiipImagineBundle 1.6.0 на Symfony 3.1.3 в сочетании с VichUploaderBundle 1.2.0 и все идет нормально на dev но на prod он не сохраняет кэшированные файлы. Изображения сохраняются корректно, так что проблема скорее не в VichUploaderBundle.

config.yml:

vich_uploader:
    db_driver: orm # or mongodb or propel or phpcr
    mappings:
            pop_image:
                uri_prefix:         /images/pops
                upload_destination: %kernel.root_dir%/../web/images/pops
            ad_image:
                uri_prefix:         /images/ads
                upload_destination: %kernel.root_dir%/../web/images/ads
liip_imagine:
    resolvers:
       default:
          web_path: ~

    filter_sets:
        cache: ~
        square:
            quality: 75
            filters:
                thumbnail: { size: [400, 400], mode: outbound }

маршрутизация.yml:

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

ветка:

...
<div class="image">
   <img src="{{ vich_uploader_asset(pop,'imageFile')|imagine_filter('square') }}" alt="{{ pop.question }}" width="100%" class="grayscale" />
   <span class="image-question">{{ pop.question }}</span>
</div>
...

person Starspire    schedule 30.07.2016    source источник
comment
Итак, проблема в том, что кэшированные файлы не создаются или URL-адрес не генерируется?   -  person Florent Destremau    schedule 30.07.2016
comment
@Florent Файлы кеша не создаются.   -  person Starspire    schedule 30.07.2016
comment
А ты кеш чистил? Проблемы между средами разработки и производства возникают из-за того, что в 90% случаев не очищается кеш! :)   -  person Florent Destremau    schedule 30.07.2016
comment
@ Флоран Да, конечно. Я начинаю думать, что это проблема конфигурации nginx. Я где-то читал, что nginx выполняет некоторые перенаправления до того, как LiipImagineBundle создаст файлы кеша.   -  person Starspire    schedule 31.07.2016


Ответы (1)


Столкнулся с похожей проблемой, но с LiipImagineBundle 2.1 на Symfony 4.2. В моем случае правило Nginx, которое я использовал для кэширования изображений, переопределяет маршрут LiipImagineBundle.

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # Cache images.
    location ~* \.(?:ico|css|gif|jpe?g|png)$ {
        expires 30d;
        add_header Vary Accept-Encoding;
        access_log off;
    }

Итак, я добавил отдельное место для /media/cache/resolve/:

    location ^~ /media/cache/resolve/ {
        try_files $uri /index.php$is_args$args;
    }

Префикс ^~ указывает Nginx прекратить поиск других расположений (подробнее о приоритете расположения Nginx).

person vely    schedule 30.09.2019
comment
Я добавил новое правило в начале, а затем в конце конфигурации: проблема остается! Я использую Liip2.3/Sym4.4 Вот весь файл конфигурации nginx: /text/uquirzbmy51zsfyu4zi9/bknz0bvihor2l3pffznt - person Sami; 06.11.2020
comment
@ Сами, я думаю, что if внутри вашего location / блокирует правило для /media/cache/resolve/. - person vely; 22.11.2020