Im using vich uploader to upload images and oneup flysystem file abstraction. Also liip imagine bundle to make thumbnails.
The problem is that liip takes my oneup flysystem adapters local path and tries to find uploads/58998d6502406.png image in it. When i remove uploads prefix, then it works else throws source file not found exception.
Maybe i am missing something in my configuration?
Twig:
<img src="{{ vich_uploader_asset(partner, 'imageFile') | imagine_filter('my_thumb') }}" /> (also tried with asset)
generated url:
http://app.dev/media/cache/resolve/my_thumb/uploads/58998d6502406.png
url that works:
http://app.dev/media/cache/resolve/my_thumb/58998d6502406.png
My configuration:
# OneupFlysystem Configuration
oneup_flysystem:
adapters:
uploads_adapter:
local:
directory: "%kernel.root_dir%/../web/uploads"
filesystems:
uploads_fs:
adapter: uploads_adapter
mount: uploads_fs
# Vich uploader Configuration
vich_uploader:
db_driver: orm
storage: flysystem
mappings:
partner_image:
uri_prefix: /uploads
upload_destination: uploads_fs
namer: vich_uploader.namer_uniqid
delete_on_remove: true
delete_on_update: true
news_image:
uri_prefix: /uploads
upload_destination: uploads_fs
namer: vich_uploader.namer_uniqid
delete_on_remove: true
delete_on_update: true
# Liip imagine bundle Configuration
liip_imagine:
loaders:
uploaded_images:
flysystem:
filesystem_service: oneup_flysystem.uploads_fs_filesystem
data_loader: uploaded_images
filter_sets :
my_thumb:
filters:
thumbnail: { size: [120, 90], mode: outbound }
Fixed by changing uri_prefix in vich uploader config to empty string uri_prefix: ""
Related
It throws this error:
Unrecognized option "handler" under "fos_user.registration.form"
And the files are:
//services.yml
app.form.registration:
class: AppBundle\Form\AccomodationFrontSignUpType
tags:
- { name: form.type, alias: app_user_registration }
app.form.handler.registration:
class: AppBundle\Form\Handler\RegistrationFormHandler
arguments: ["#fos_user.registration.form", "#request", "#fos_user.user_manager", "#fos_user.mailer", "#fos_user.util.token_generator"]
scope: request
public: false
//config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
group:
group_class: AppBundle\Entity\Group
service:
mailer: swiftmailer.mailer.strato
from_email:
address: webmyhomepage#strato.com
sender_name: myHomepage
registration:
form:
handler: app.form.handler.registration
type: app_user_registration
confirmation:
template: FOSUserBundle:Registration:email.txt.twig
enabled: true
Any help is welcome, thanks
The error means that there is an invalid parameter in your config. The key handler in your config
-> handler: app.form.handler.registration
if you take a look inside the fos user bundle DependencyInjection folder, Configuration.php file, that option does not exist. so its invalid :).
There you can see witch options are available. In my current version of this bundle i have this options available under form: type, name, validation_groups.
Also you can see the default configuration for a bundle with:
php app/console debug:config FOSUserBundle
When I want to create a Shipment I get the error:
An exception has been thrown during the rendering of a template ("No locale has been set and current locale is undefined.") in SonataAdminBundle::standard_layout.html.twig at line 148.
I think I need to set the default locale for sylius, but I tried alot of examples, none of them helped..
I currently have this setup:
Config.yml:
sylius_shipping:
driver: doctrine/orm # Configure the Doctrine ORM driver used in documentation.
classes:
shipping_method:
model: Application\Sylius\ShippingBundle\Entity\ShippingMethod
translation:
model: Application\Sylius\ShippingBundle\Entity\ShippingMethodTranslation
shipping_method_rule:
model: Application\Sylius\ShippingBundle\Entity\Rule
shipment:
model: Application\Sylius\ShippingBundle\Entity\Shipment
shipment_item:
model: Application\Sylius\ShippingBundle\Entity\ShipmentItem
shipping_category:
model: Application\Sylius\ShippingBundle\Entity\ShippingCategory
#stof_doctrine_extensions:
# orm:
# default:
# timestampable: true
parameters:
sylius.locale: %locale%
#sylius_locale:
# driver: doctrine/orm
sylius_translation:
default_locale: "%locale%"
#sylius_translation:
# default_locale: %sylius.locale%
Parameters.yml:
sylius.currency_importer.ecb.base_currency: EUR
sylius.currency_importer.open_exchange_rates: EDITME
sylius.locale: en_US
Nothing works..
UPDATE
By changing my config to this:
framework:
#esi: ~
translator: { fallback: %sylius.locale% }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%sylius.locale%"
parameters:
sylius.locale: 'en'
#sylius_locale:
# driver: doctrine/orm
sylius_translation:
default_locale: %sylius.locale%
I still get the same error. I cleared my cache.
Try %sylius.locale%. It looks like you've just not put in the full name of the parameter in your config file.
If you've updated the value and it's not working, make sure you clear your cache.
$ app/console cache/clear --env=dev
$ app/console cache/clear --env=prod
You will also require something like this:
imports:
- { resource: parameters.yml }
Otherwise the parameters you enter will not be loaded into the configuration file.
I have my model entities saved in src/AppBundle/Model/Entity.
You can understand, that i have own custom folder for entities (in model folder).
This is my orm settings in config.yml:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: false
mappings:
user:
type: annotation
dir: %kernel.root_dir%/../src/AppBundle/Model/Entity
alias: 'Entity'
prefix: AppBundle\Model\Entity
is_bundle: false
I have a problem with these lines in my security.yml:
providers:
our_db_provider:
entity:
class: AppBundle:User
property: username
# if you're using multiple entity managers
# manager_name: customer
There is some error:
Unknown Entity namespace alias 'AppBundle'.
I don't what ref I have to use (AppBundle:User probably not).
Thank you for your answers.
By default, all Symfony bundles will have a nice alias: XxxBundle (aliasing the NamespaceOfXxxBundle\Entity namespace). As you're bundle doesn't follow this convention and stores it in Model\Entity instead, you have 2 options:
Don't use the alias feature and pass the FQCN: AppBundle\Model\Entity\User
Create a new alias, give it a nice name and use it:
doctrine:
orm:
# ...
mappings:
user:
type: annotation
dir: %kernel.root_dir%/../src/AppBundle/Model/Entity
alias: App # <-- the alias name
prefix: AppBundle\Model\Entity
is_bundle: false
App:User
I am struggling to define entity mapper found here:
https://github.com/Payum/PayumBundle/blob/master/Resources/doc/capture_funds_with_paypal_express_checkout.md#2-a-configure-doctrine-storage
payum:
contexts:
your_context_name:
doctrine_storage:
driver: orm
model_class: AcmeDemoBundle\Entity\PaypalPaymentInstruction
doctrine:
orm:
entity_managers:
default:
mappings:
payum_paypal_express_checkout_nvp:
is_bundle: false
type: xml
dir: %kernel.root_dir%/../vendor/payum/paypal-express-checkout-nvp/src/Payum/Paypal/ExpressCheckout/Nvp/Bridge/Doctrine/Resources/mapping
prefix: Payum\Paypal\ExpressCheckout\Nvp\Bridge\Doctrine\Entity
My current doctrine configuration is having an autoload to true. Problem I have is to make this mapping work with my autoload: true
I can get mapping to work when i remove my autoload: true but
Any tips would be much appreciated, but question is how do i create a table from this mapping information?
This config works well for me. It added an id feild(it is come from bundle and was automapped) and the rest field come from manually defined mapping.
I added an example to sandbox. It works fine.
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
mappings:
payum_paypal_express_checkout_nvp:
is_bundle: false
type: xml
dir: %kernel.root_dir%/../vendor/payum/paypal-express-checkout-nvp/src/Payum/Paypal/ExpressCheckout/Nvp/Bridge/Doctrine/Resources/mapping
prefix: Payum\Paypal\ExpressCheckout\Nvp\Bridge\Doctrine\Entity
I use VichUploaderBundle for upload my media files and I want to use AvalancheImagineBundle to create thumbs in my templates.
How it should be done?
I have this right now:
<td><img src="{{ vich_uploader_asset(entity, 'image') | apply_filter('my_thumb')}}" alt="{{ entity.nombre }}" /></td>
But the output is:
<img src="/app_dev.php/media/cache/my_thumb/images/uploads/392158_10150441208223772_580903771_8591661_774015725_n.jpg" alt="Froga"/>
this is my config.yml:
# Vich Uploader
vich_uploader:
db_driver: orm
twig: true
gaufrette: false # set to true to enable gaufrette support
storage: vich_uploader.storage.file_system
mappings:
uploads:
uri_prefix: /images/uploads
upload_destination: %kernel.root_dir%/../web/images/uploads
namer: ~ # specify a file namer service id for this entity, null default
directory_namer: ~ # specify a directory namer service id for this entity, null default
delete_on_remove: true # determines whether to delete file upon removal of entity
inject_on_load: true # determines whether to inject a File instance upon load
avalanche_imagine:
source_root: %kernel.root_dir%/../web/images/uploads
web_root: %kernel.root_dir%/../web/images/uploads
cache_prefix: media/cache
driver: gd
filters:
my_thumb:
type: thumbnail
options: { size: [120, 90], mode: outbound, quality: 100, format: png }
Any help or clue?
If the problem you are having is that no image is being displayed, then I had the same issue.
In order to solve it I ensured that within my config.yml, the source_root and web_root options of avalanche_imagine were set to %kernel.root_dir%/../web (or your web root). Here is the relevant snippet from my config.yml:
#Uploads
knp_gaufrette:
adapters:
article_adapter:
local:
directory: %kernel.root_dir%/../web/images/articles
filesystems:
article_image_fs:
adapter: article_adapter
vich_uploader:
db_driver: orm
gaufrette: true
storage: vich_uploader.storage.gaufrette
mappings:
article_image:
uri_prefix: /images/articles
upload_destination: article_image_fs
namer: vich_uploader.namer_uniqid
#images
avalanche_imagine:
filters:
article_list:
type: thumbnail
options: { size: [100, 100], mode: outbound }
source_root: %kernel.root_dir%/../web
web_root: %kernel.root_dir%/../web
cache_prefix: cache
Nothing wrong with that. Imagine bundle in production generates thumbnail the first time its called and stores it in web/media folder. On second call it just reads from web/media.
It has some advantages to modify the thumnail sizes at will. If You are worried about performance you should fire some job to generate thumbnail after the upload is finished,
although i used it like that and never complained.
In my case, I chose to use LiipImagineBundle which is a fork of the AvalancheImagineBundle
.
I were configure this bundle to use gaufrette as data-loader, than it simple to use it as you describe, without caring much about the paths.