PHP致命错误:未找到“Eloquent”类

时间:2016-08-05 15:38:52

标签: php laravel laravel-5 eloquent

我有一个脚本

<?php

    require_once "vendor/autoload.php";
    Dotenv::load(__DIR__);


    use \App\VSE, \App\User;
    // use Eloquent;

    $accounts = VSE::account_all();
    $accounts = json_decode (json_encode ($accounts), FALSE);

    foreach ($accounts as $account) {

        $user = new User;
        $user->id = $account->account_id;
        $user->account_id = $account->account_id;
        $user->email = $account->email_address;
        $user->auto_provisioning = null;
        $user->service_plan = null;
        $user->fb_email = '';
        $user->tw_email = '';
        $user->fb_access_token = '';
        $user->fb_profile_id = '';
        $user->fb_page_id = '';
        $user->fb_username = '';
        $user->save();
    }

?>

我一直在

  

PHP致命错误:第6行的/Applications/MAMP/htdocs/code/portal/app/User.php中找不到类'Eloquent'

我该如何避免?

1 个答案:

答案 0 :(得分:0)

看起来用户模型正在使用Eloquent。

您是否尝试在独立应用中使用Eloquent?为了做到这一点,需要进行一些设置......请参见此处的示例:

https://github.com/illuminate/database

你的composer.json中有什么?