Welcome Guest, Not a member yet? Register   Sign In
Custom Config Loading Issue
#1

[eluser]Robbkore[/eluser]
Hello All,

I have run into a rather strange issue and am having some trouble tracing what the problem is. I am loading a configuration array from a config file called admin.php. When I load this locally the array loads correctly and the output processes as expected. When I load this onto my web server, however, it raises an error that the config is not a valid configuration array. Below is the code and as you can see, the array is $config as per the CI manual. I have had this problem in both CI 1.6+ and CI 2.0. I'm using the HMVC module and a template class in the code but have bypassed both for testing purposes.

config/admin.php
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
//This file stores configuration variables for the website not defined in the default config files

// Basic Settings for admin area
$config['admin_email'] = '[email protected]';
$config['admin_controller'] = 'admin/';

// Load all editale pages for use in admin menu
$CI = &get;_instance();
$CI->load->model('content_model');
$pages = $CI->content_model->get_links();

// Get pages into array for menu
$i = 0;
foreach($pages as $page)
{
    $links[ucwords(str_replace("-", " ", $page->uri))] = $config['admin_controller'].'content/edit/'. $page->uri;
    $i++;
}

// Modules for Admin Menus
$config['admin_modules']['Settings'] = array(
    'Site Settings' => $config['admin_controller'].'settings',
    'Maintenance Mode' => $config['admin_controller'].'settings/maintenance'    
);

// Display each editable page
$config['admin_modules']['Content'] = $links;

// Regular Member options
$config['admin_modules']['Members'] = array(
    'View Members' => $config['admin_controller'].'members',
    'Add Member' => $config['admin_controller'].'members/edit'
);

// Board Member options
$config['admin_modules']['Board Members'] = array(
    'View Board Members' => $config['admin_controller'].'board_members',
    'Add Board Member' => $config['admin_controller'].'board_members/edit'
);

// Events
$config['admin_modules']['Events'] = array(
    'Event List' => $config['admin_controller'].'events',
    'Edit Meeting Info' => $config['admin_controller'].'events/meetings',
    'Add Event' => $config['admin_controller'].'events/add'
);    
/*
$config['admin_modules']['Applications'] = array(
    'View Submissions' => $config['admin_controller'].'applications',
    'View Applicants' => $config['admin_controller'].'members/applicants',
);
*/    

// Stats
$config['admin_modules']['Statistics'] = array(
    'Site Statics' => $config['admin_controller'].'stats'
);

controllers/testing.php
Code:
<?php
class Testing extends CI_Controller
{
    function index()
    {
        $this->load->model('admin/content_model');    
        $this->load->config('admin');
        echo "<pre>";
        print_r($this->config->item('admin_modules'));
        echo "</pre>";        
    }    
}

When loading the above controller on my local machine I can see the array perfectly fine but running it on my live server I get "Your application/config/admin.php file does not appear to contain a valid configuration array."

Local PHP Version is 5.2.9 and server is 5.2.4. The live host is a hostgator account.

Any ideas/suggestions? I've searched the forum but haven't had much luck finding this particular issue.
#2

[eluser]Robbkore[/eluser]
I renamed the file from config/admin.php to config/Admin.php and the error message indicated the config file did not exist. I renamed the file back to config/admin.php and it started working, but is now loading the entire array as a single multi-dimensional array instead of an array for each key. I'm guessing this has something to do with the server version of PHP or some setting there and am working out how to backtrace and fix this, very odd that it would suddenly work after renaming the file though.




Theme © iAndrew 2016 - Forum software by © MyBB