Error - Class 'Auth' not found in PKGPATH/oil/classes/console.php(116) : eval()'d code on line 1
FuelPHPでError - Class 'Auth' not found in PKGPATH/oil/classes/console.php(116) : eval()'d code on line 1とエラーが出たときの対処方になります。
どんな時に出る?
コマンドからデータベースのテストユーザーを登録しようとしたときにでました。 [c] $ cd /var/www/html/FuelPHP(プロジェクト名) $ oil console Fuel 1.8 - PHP 7.0.7 (cli) (May 25 2016 18:27:57) [Linux]
[/c] とでるので、テストユーザー登録をしようとしました。 [c] $ oil console Fuel 1.8 - PHP 7.0.7 (cli) (May 25 2016 18:27:57) [Linux]
Auth::create_user('admin', 'pass', 'test@example.com'); Error - Class 'Auth' not found in PKGPATH/oil/classes/console.php(116) : eval()'d code on line 1 [/c] となりました。どうやらあconfig.phpをいじることで解決するみたいです。
app/config/config.phpの設定を変える
config.phpのalways_loadのコメントアウトを外してauthを追加することで解決します。
/**************************************************************************/
/* Always Load */
/**************************************************************************/
'always_load' => array(
/**
* These packages are loaded on Fuel's startup.
* You can specify them in the following manner:
*
* array('auth'); // This will assume the packages are in PKGPATH
*
* // Use this format to specify the path to the package explicitly
* array(
* array('auth' => PKGPATH.'auth/')
* );
*/
'packages' => array(
//'orm',
'email',
'auth',
),
/**
* These modules are always loaded on Fuel's startup. You can specify them
* in the following manner:
*
* array('module_name');
*
* A path must be set in module_paths for this to work.
*/
// 'modules' => array(),
/**
* Classes to autoload & initialize even when not used
*/
// 'classes' => array(),
/**
* Configs to autoload
*
* Examples: if you want to load 'session' config into a group 'session' you only have to
* add 'session'. If you want to add it to another group (example: 'auth') you have to
* add it like 'session' => 'auth'.
* If you don't want the config in a group use null as groupname.
*/
// 'config' => array(),
/**
* Language files to autoload
*
* Examples: if you want to load 'validation' lang into a group 'validation' you only have to
* add 'validation'. If you want to add it to another group (example: 'forms') you have to
* add it like 'validation' => 'forms'.
* If you don't want the lang in a group use null as groupname.
*/
// 'language' => array(),
),
