CodeIgniter Forums
How to load Configuration Files as Array? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How to load Configuration Files as Array? (/showthread.php?tid=74397)



How to load Configuration Files as Array? - bustersg - 09-18-2019

I am passing some environment settings to a view template but how do I pass it as an Array to avoid below error?

TypeError
Argument 2 passed to view() must be of the type array, object given

PHP Code:
<?php namespace Config;

use 
CodeIgniter\Config\BaseConfig;

class 
TestConfig extends BaseConfig
{
    /*
    |--------------------------------------------------------------------------
    | CAPTCHA
    |--------------------------------------------------------------------------
    |
     */
    public $captcha 1


PHP Code:
// Access config class with namespace
$config config'Config\\TestConfig' );

echo view('login', $config); 



RE: How to load Configuration Files as Array? - dave friend - 09-18-2019

Try

PHP Code:
// Access config class with namespace
$config config'Config\\TestConfig' );
$data['captcha'] = $config->captcha;
echo 
view('login'$data);