duai5344 2018-09-15 11:44
浏览 100

我的localhost apache在php slim应用程序中无法识别

In my app.php I got this

<?php

use Cart\App;
use Illuminate\Database\Capsule\Manager as Capsule;
session_start();

require __DIR__ . '/../vendor/autoload.php';

$app = new App;

$capsule = new Capsule;

$capsule->addConnection([

'driver' => 'mysql',
'host' => 'localhost',
'database' => 'cart',
'username' => 'root',
'password' => 'root',
'charset' =>'utf8',
'collation' =>'utf8_unicode_ci',
'prefix' => ''

]);


$capsule->setAsGlobal();
$capsule->bootEloquent();
require __DIR__ . '/../app/routes.php';

and in my HomeController.php i got this

<?php

namespace Cart\Controllers;

use Slim\Views\Twig;
use Cart\Models\Product;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class HomeController

{
    public function index(Request $request, Response $response, Twig $view, Product $product)
    {

           $products = $product->get();
           var_dump($products);
           die();
        return $view->render($response, 'home.twig');
    }
}

And if run it in localhost/cart/public I got this Error Message :

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from products)

Why doesn't this recognize my localhost? I use xamppp

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献