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 聚类分析或者python进行数据分析
    • ¥15 如何用visual studio code实现html页面
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?