0

I am trying to store an array in a config file `config/project_specific.php

<?php

return [
    'sluggable_models1' => 'test_value', // works
    'sluggable_models2' => ['features','packages'], // throws error
];

I call this value by $models = config('project_specific.sluggable_models') in my controller

problem

as long as the variable is a string, it works. When the value is an array type, i get this error ErrorException in helpers.php line 515: htmlentities() expects parameter 1 to be string, array given (View: \resources\views\starter\admin\dashboard_admintools.blade.php)

to do

how I can store a sitewide accessible array in my Laravel 5.3 app? Not necesarily a config file, but I prefer to avoid a DB-fed solution.

3
  • 1
    The error seems to indicate the array is making it to your view just fine but you are trying to print the variable in your blade template vs. looping over it. Your config file is fine...I routinely have arrays with multiple sub arrays in my config files. Can you add your view code? Commented Aug 25, 2016 at 0:24
  • That was so obvious. Thank you! Whether you upgrade your hint to an answer, it's up to you. Commented Aug 25, 2016 at 1:57
  • no problem! Sometimes it takes a fresh set eyes Commented Aug 25, 2016 at 2:00

1 Answer 1

1

The error seems to indicate the array is making it to your view just fine but you are trying to print the variable in your blade template vs. looping over it.

{{ }} is essentially the same as echo but it tries to escape the string using htmlentities(), hence the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.