Call to undefined method CONFIG::get()

我想在应用程序的控制器端获取配置文件中的变量
控制器的代码如下

<?php
error_reporting(E_ERROR);
class MyApp extends BaseController
{
private $root;
public $etw;
public function MyApp()
{
$config = App::make('CONFIG');
$init = $config->init();
$this->root = $init['root'];
}
public function reg(){
$etw = App::make('ETW');
$ip = $etw->getip();
$head = array('title'=>'ETW international','KD'=>'ETW','des'=>'ETW');
$path = $this->root;
$username = Session::get('username');
$username = $username==''?null:$username;
Config::get('app.url');
return View::make('reg.login',compact('ip','head','path','username'));
}
}
?>
但报下面错误
production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method CONFIG::get()' in /var/www/html/FileModifyCheck/app/controllers/MyApp.php:20
Stack trace:

0 [internal function]: Illuminate\Exception\Handler->handleShutdown()

1 {main} [] []

求帮助~~~~~
非常感谢。。。。。
已邀请:

FiveSay - 成武

赞同来自:

$config = App::make('CONFIG'); 注意大小写。

mysteo

赞同来自:

$config = App::make('CONFIG');
误导了
上面的是正确的

在程序下面有一个地方报错
Config::get('app.url');
我是准备获取config/app.php中的url变量

mysteo

赞同来自:

找到问题了
由于上面定义了一个类CONFIG.php

$config = App::make('CONFIG');
下面再引用系统自带的Config::get('url');

系冲突所致,删除上面的自定义方法,可以解决这个问题
error_reporting(E_ERROR);
//use \etw\appconfig as etwConf;
class MyApp extends BaseController
{
private $root;
public $etw;
public function MyApp()
{
//$config = App::make('CONFIG');
//$init = $config->init();
//$this->root = $init['root'];
}
public function reg(){
$etw = App::make('ETW');
$ip = $etw->getip();
$head = array('title'=>'ETW international','KD'=>'ETW','des'=>'ETW');
$path = '';
$username = Session::get('username');
$username = $username==''?null:$username;
$info = Config::get('app.url');
return View::make('reg.login',compact('ip','head','path','username'));
}
}

安正超

赞同来自:

另外在这里贴代码的时候使用 {{{这里是代码}}} 更容易看些

要回复问题请先登录注册