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とエラーが出たときの対処方になります。
どんな時に出る?
コマンドからデータベースのテストユーザーを登録しようとしたときにでました。
1 | $ cd /var/www/html/FuelPHP(プロジェクト名) |
2 | $ oil console |
3 | Fuel 1.8 - PHP 7.0.7 (cli) (May 25 2016 18:27:57) [Linux] |
4 | >>> |
とでるので、テストユーザー登録をしようとしました。
1 | $ oil console |
2 | Fuel 1.8 - PHP 7.0.7 (cli) (May 25 2016 18:27:57) [Linux] |
3 | >>> Auth::create_user( 'admin' , 'pass' , 'test@example.com' ); |
4 | Error - Class 'Auth' not found in PKGPATH/oil/classes/console.php(116) : eval()'d code on line 1 |
となりました。どうやらあconfig.phpをいじることで解決するみたいです。
app/config/config.phpの設定を変える
config.phpのalways_loadのコメントアウトを外してauthを追加することで解決します。
01 | /**************************************************************************/ |
02 | /* Always Load */ |
03 | /**************************************************************************/ |
04 | 'always_load' => array ( |
05 |
06 | /** |
07 | * These packages are loaded on Fuel's startup. |
08 | * You can specify them in the following manner: |
09 | * |
10 | * array('auth'); // This will assume the packages are in PKGPATH |
11 | * |
12 | * // Use this format to specify the path to the package explicitly |
13 | * array( |
14 | * array('auth' => PKGPATH.'auth/') |
15 | * ); |
16 | */ |
17 | 'packages' => array ( |
18 | //'orm', |
19 | 'email' , |
20 | 'auth' , |
21 | ), |
22 |
23 | /** |
24 | * These modules are always loaded on Fuel's startup. You can specify them |
25 | * in the following manner: |
26 | * |
27 | * array('module_name'); |
28 | * |
29 | * A path must be set in module_paths for this to work. |
30 | */ |
31 | // 'modules' => array(), |
32 |
33 | /** |
34 | * Classes to autoload & initialize even when not used |
35 | */ |
36 | // 'classes' => array(), |
37 |
38 | /** |
39 | * Configs to autoload |
40 | * |
41 | * Examples: if you want to load 'session' config into a group 'session' you only have to |
42 | * add 'session'. If you want to add it to another group (example: 'auth') you have to |
43 | * add it like 'session' => 'auth'. |
44 | * If you don't want the config in a group use null as groupname. |
45 | */ |
46 | // 'config' => array(), |
47 |
48 | /** |
49 | * Language files to autoload |
50 | * |
51 | * Examples: if you want to load 'validation' lang into a group 'validation' you only have to |
52 | * add 'validation'. If you want to add it to another group (example: 'forms') you have to |
53 | * add it like 'validation' => 'forms'. |
54 | * If you don't want the lang in a group use null as groupname. |
55 | */ |
56 | // 'language' => array(), |
57 | ), |
個人支援・寄付について
サイトラボでは個人支援・寄付を受けております。ご協力いただける方はお願いいたします。当サイトではビットコインで受け付けております。
- ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS