Illegal string offset 'image_size' error after installation
Ardakilic opened this issue · comments
Hey,
Firstly, thanks for the plugin! it's much appreciated!
I have an issue, I hope you can help me:
My Laravel version is 4.1.24
arda@arda-pc ~/web/mywork $ php artisan --version Laravel Framework version 4.1.24
This is my PHP Version (using Linux Mint 16 x64):
PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:06:05) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
After installation, when I add the service provider in app/config/app.php
, I get an error like this:
Illegal string offset 'image_size'
File: /home/arda/web/mywork/vendor/cviebrock/image-validator/src/Cviebrock/ImageValidator/ImageValidatorServiceProvider.php
Error is showing this method on Whoops:
protected function extendValidator($rule) { $method = studly_case($rule); $translation = $this->app['translator']->get('image-validator::validation'); $this->app['validator']->extend($rule, 'Cviebrock\ImageValidator\ImageValidator@validate' . $method, $translation[$rule]); $this->app['validator']->replacer($rule, 'Cviebrock\ImageValidator\ImageValidator@replace' . $method ); }
How can I fix this?
Edit: I've found a temporary fix, by adding a tr/validation.php
(my language setting is tr) into your src folder, I've tried adding them to my app/lang/tr/validation.php
but that didn't work.
Is there a proper workaround?
Thanks,
Did your pull request solve the issue, or do I need to look at the validator code some more?
@cviebrock My pull request solved the issue on my end indeed, but I guess this should be mentioned somewhere on readme.md
for the people using other foreign languages. Because both artisan and routes starts to throw errors unless a language file is added.
I would recommend a different approach (the Laravel approach):
Put your custom validation.php (if you're using a language that is not en) into the folder
app/lang/your_lang_code/packages/image-validator/
So in my case that'd be
app/lang/de/packages/image-validator/
I still have this issue on my side ;)
Edit: No errors anymore when adding 'fallback_locale' => 'en'
to app/config/app.php
.
I think this has sorted itself out now, so closing.
If you have a locale as es-ES or es-US don't work. You need something more flexible for the languages file. My fallback_locale can't be 'en', it is 'es-US'.
I try to put the validation file several ways in lang folder but without success!
The package is perfect, and I need it!! ;)
@dhardtke was wrong. the good route to save the language file in your lang folders are:
app/lang/packages/your_lang_code/packages/image-validator/
Now is more flexible :)