douci2015 2015-06-27 18:51
浏览 117

Laravel 5找不到驱动程序问题

I am relatively new to Laravel 5.1 and version control with Laravel. I created an Eloquent model named Article. I have a route that goes to the articles controller with the proper reference to a class. But in the Controller I referenced back to the article controller to get a JSON list of all entries in the articles in the database.

So here is the error I got:

PDOException in Connector.php line 50:
could not find driver
in Connector.php line 50
at PDO->__construct('mysql:host=localhost;dbname=mantella', 'root', 'root', array('0', '2', '0', false, false)) in Connector.php line 50


So initially I thought I might have set the driver wrong or input the incorrect database login. I set up the database information in the.env file. But all of the information in the .env file was correct.
Any way here is my Article Model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    protected $fillable = [
        'title',
        'body',
        'published_at'
    ];
}

And here is the controller:

<?php

namespace App\Http\Controllers;

use App\Article;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class ArticlesController extends Controller
{
    public function index()
    {
        $articles = Article::all();

        return $articles;
    }
}

Just to be safe here is the route:

<?php

Route::get('articles', 'ArticlesController@index');

I went into php artisan for laravel and used tinker. I typed $article = App\Article::get(); and that displayed all of the information in the database. I could have easily missed something. Can someone help me figure out why it isn't working in the controller and why it worked in tinker?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?