目前无法处理此请求

时间:2018-05-19 07:37:05

标签: php namespaces composer-php

我有这个目录结构

hosting 
  app 
  database
    Database.php
  view
    index.php
  vendor
    autoload.php

这是索引的代码     

# Load env
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();

use \Database\Database as Db;

# database connection
$database = new Db();
d($database);
exit;

这是作曲家json中的内容

{
  "name": "Sale App",
  "description": "m.",
  "keywords": ["sale"],
  "license": "MIT",
  "type": "project",
  "require": {
      "kint-php/kint": "^2.2",
      "vlucas/phpdotenv": "^2.4"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Database\\": "database/"
    }
  }
}

这是database.php的部分代码

<?php
namespace Database;

class Database extends mysqli
{
    private $host = 'localhost';
    private $dbname = 'abchosting';
    private $user = 'root';
    private $pswd = 'password';
    private $log  = true;

    /**
     * make instance of the class
     */
    public function __construct()
    {
      d('yes');
      exit;

      parent:: __construct($this->host, $this->user, $this->pswd, $this->dbname);
      $this->set_charset("utf8");

      if ( mysqli_connect_error() )
      {
        if( $this->log )
        error_log( '[ CLASS: Database.php ] [ ERROR: __construct ] Connection error '.$this->gstNameDB.': Error No. ' . mysqli_connect_errno() . ' : '. mysqli_connect_error());

        die('[ CLASS: Database.php ] [ ERROR: __construct ] Connection error '.$this->gstNameDB.': Error No. ' . mysqli_connect_errno() . ' : '. mysqli_connect_error());
      }
    }

但是当在chrome中查看时, 它说

is currently unable to handle this request.

使用命名空间和编写器这个简单的实现我错了吗?

0 个答案:

没有答案