I use liip imagine on symfony 6 and I have a problem with images.
I use deployer.php for the deployment of my project and my images are in a shared folder which looks like this: /var/www/shared/public/images.
the image url looks like this:
https://monurl.fr/media/cache/resolve/miniature/image.png
but it does not display anything despite the image being in the directory. The thumbnail directory is not generated by liip in the public/media/cache directory.
On the other hand I have other images which are not in the shared folder and which are well generated.
Here is the imagine liip file configuration.
# Documentation on how to configure the bundle can be found at:
https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html
liip_imagine:
driver: "imagick"
filter_sets:
miniature:
cache: default
quality: 50
filters:
scale:
dim: [ 400,400 ]
photos:
cache: default
quality: 50
filters:
scale:
dim: [ 1200,1200 ]
If you have an idea how to manage the shared folder of deployer with liip I'm interested. Thanks for your help.
Related
I would like to exclude fields when exposing my API from my user class that extends FOSUser.
I've setup JMS Serializer on the global config file and created a FOSUB config to only expose the fields I need.
Global Config:
app/config/config.yml
jms_serializer:
metadata:
directories:
FOSUB:
namespace_prefix: "FOS\\UserBundle"
path: "#AppBundle/Resources/config/serializer/fos"
FOS config file:
src/AppBundle/Resources/config/serializer/fos/Model.user.yml
FOS\UserBundle\Model\User:
exclusion_policy: ALL
properties:
id:
expose: true
email:
expose: true
roles:
expose: true
This config is working perfectly on my local machine however it doesn't work when deployed on prod. Both use same stack, my guess is that on prod somehow the serializer can't find FOS config file.
Any help would be much appreciated.
The issue was somehow related to the naming of the config file.
While in local (macos) the file name Model.user.yml was working, in production (centos) it didn't work. So I had to rename the file to Model.User.yml then it worked fine on both.
I tried to find some documentation related to this issue but couldn't find any.
Take away: Make sure that the config file name represent exactly the entity you want to override.
I use the php-translation bundle.
When I edit a value for a translation key in the debug bar and sync it, then a .xlf file gets automatically created in the app/Resources/translations folder and it provides the translation key with value that I edited in the debug bar.
What I actually want to have is that the value of the translation key gets updated in the .yml file in the src/UserBundle/Resources/translations file that I have already created.
Is there any possibility to configure the bundle that way?
You can specify the output folder. From the php-translation documentation:
translation:
locales: ["en", "fr", "sv"]
configs:
app:
dirs: ["%kernel.root_dir%/Resources/views", "%kernel.root_dir%/../src"]
output_dir: "%kernel.root_dir%/Resources/translations"
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]
I use behat v3.0.15 and i want to put my features in the ./app/features reposistory.
As i can read in the documentation http://docs.behat.org/en/v3.0/guides/6.profiles.html#custom-autoloading all i have to do is to add theses lines in my behat.yml file
# behat.yml
default:
autoload:
'': %paths.base%/app/features/bootstrap
Sadly it doesn't work
When i try to init behat with this command ./bin/behat --config ./app/config/behat.yml --init, the program creates a features folder under the config folder.
So what can i do?
You've configured autoloader. Location of features is configured in paths section.
default:
autoload: %paths.base%/app/features/bootstrap
suites:
default:
paths:
- %paths.base%/app/features
Configuration of paths and autoloader is documented on different pages, so it's confusing. Behat 2.5 documentation is little better (but yaml structure is different).
Example is taken from feature test for custom paths
This is how you can define your customized php featureContext files:
autoload:
'': %paths.base%/features/bootstrap
suites:
default:
contexts:
-
I've installed Sylius and I need to change "web" directory to "www". I have followed official Symfony instructions. The problem is images of products and categories don't load. I have been digging in "config.yml" and I have changed:
liip_imagine:
web_root: %kernel.root_dir%/../www/media/image
data_root: %kernel.root_dir%/../www/media/image%
And also I have changed:
knp_gaufrette:
adapters:
sylius_image:
local:
directory: %kernel.root_dir%/../www/media/image
create: true
But it's still not working.
Do you know if it's needed to change anything else?
I have found the trick. In order to images be shown you have to edit "app/config/config.yml":
liip_imagine:
web_root: %kernel.root_dir%/../www
data_root: %kernel.root_dir%/../www/media/image
And now images for products and categories are shown correctly.
I have been trying for a few days to get Sonata Media Bundle working inside Symfony. I have reinstalled it a few times in different orders, and all sorts. Every time I install I get the following error:
[RuntimeException]
The autoloader expected class "Sonata\MediaBundle\Document\ODM\BaseGallery" to be defined in file "/vagrant/app/../vendor/bundles/Sonata/MediaBundle/Document/ODM/BaseGallery.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
I can see it is trying to load a Document. I have a mongodb database configured but I am not using it yet, and am using MySQL primarily.
I can mess around with the namespace inside these files which obviously fixes this error, but just causes lots of different errors, and I shouldn't need to do this anyway.
Setup: (default ATM from docs) - config.yml
sonata_media:
default_context: default
db_driver: doctrine_orm # or doctrine_mongodb
contexts:
default: # the default context is mandatory
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
cdn:
server:
path: /uploads/media # http://media.sonata-project.org/
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
Think it's a bug - I have just submitted a pull request to fix it.
https://github.com/sonata-project/SonataMediaBundle/pull/134