ci 3.0有誰在用,自動載入設定檔貌似有問題啊

來源:互聯網
上載者:User
/*| -------------------------------------------------------------------|  Auto-load Config files| -------------------------------------------------------------------| Prototype:||$autoload['config'] = array('config1', 'config2');|| NOTE: This item is intended for use ONLY if you have created custom| config files.  Otherwise, leave it blank.|*///我是這樣配置的$autoload['config'] = array('routes');


報錯如下:Your /var/www/config/routes.php file does not appear to contain a valid configuration array.
百思不得其解撒


回複討論(解決方案)

在自訂設定檔中需要注意的一點就是,你所有的配置資料都 需要放到全域的組態變數$config中。
載入自訂配置的這個方法,非要在自訂設定檔中找到$config這個變數才罷休,否則就是不合法的。

例如你的 routes.php
有一下配置
$routes = array(
'a' => 1,
'b' => 2
);
在 routes.php 中加入
$config['routes'] = $routes;
參考: http://coderaladdin.com/config-class-in-codeigniter/

Your /var/www/config/routes.php file does not appear to contain a valid configuration array.
routes.php 中沒有包含有效配置數組

你的 routes.php 中都是些什麼呢?

把你的 routes.php 黏貼過來看看

在自訂設定檔中需要注意的一點就是,你所有的配置資料都 需要放到全域的組態變數$config中。
載入自訂配置的這個方法,非要在自訂設定檔中找到$config這個變數才罷休,否則就是不合法的。



感謝,這個資料其實之前看過,當時沒弄懂,現在懂了
也就是說,必須要在被自動載入的設定檔中加上一句:
$config['自訂名稱'] = $組態變數;
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.