PHP 自动加载在 php 项目中找不到该类



项目文件结构我得到

127.0.0.1:52368 [500]: GET /controllers/login - Uncaught Error: Class "AppCoreDatabase" not found in /path/to/my/Php/project/src/controllers/index.php:9
Stack trace:
#0 {main}
thrown in  /path/to/my/Php/project/src/controllers/index.php on line 9

和触发错误的类

<?php
namespace Appcontrollers;
use AppCoreDatabase;
//$conn = Database::getConnection();
try {
$conn = new Database(__DIR__ . './../config.php');
} catch (Exception $e) {
}
$query = "SELECT id, username, image, aboutme
FROM users
LEFT JOIN persons on users.id = persons.user_id
LIMIT 24";
$tbh = $conn->prepare($query);
$tbh->execute();
$persons = $tbh->fetchAll();
require_once basename("/") . 'views/index.view.php';

also my autoload_classmap.php

return array(
'App\Core\Database' => $baseDir . '/src/Core/Database.php',
'App\Core\DotEnv' => $baseDir . '/src/Core/DotEnv.php',
'App\Core\Router' => $baseDir . '/src/Core/Router.php',
'App\Entity\Person' => $baseDir . '/src/Entity/Person.php',
'App\Entity\User' => $baseDir . '/src/Entity/User.php',

我从src启动服务器目录:php -S localhost:8000任何帮助都会很感激。谢谢你。

编辑……我从url: localhost:8000调用index。php即使是index。php

中的代码
<?php
namespace App;

//use AppcoreDatabase;
use AppCoreRouter;

require 'functions.php';

//$config = require_once ('config.php');
//$db = new Database($config);

//require 'Entity/User.php';

$uri = parse_url($_SERVER['REQUEST_URI'])['path'];

$router = new Router();
$router->getRoute($uri);


//require 'router.php';
I'm getting 
127.0.0.1:53738 [500]: GET / - Uncaught Error: Class "AppCoreRouter" not found in

您必须创建一个类并在其中添加数据。

准备(查询);《旅-> execute ();$persons = $tbh->fetchAll();Require_once basename("/")。"视图/index.view.php";}

相关内容

  • 没有找到相关文章

最新更新