gpt4 book ai didi

php - 在 Phalcon 2 中找不到类用户

转载 作者:行者123 更新时间:2023-11-28 23:34:31 26 4
gpt4 key购买 nike

所以基本上我只是在我的 ubuntu 机器上安装了 Phalcon 2.0,并安装了 apache2、mysql 和所有东西。我直接进入了 Phalcon 的文档以开始使用。按照他们的 tutorial 中的确切步骤操作后,我得到了这个错误:

Fatal error: Class 'Users' not found in /var/www/html/phalcon/tutorial/app/controllers/SignupController.php on line 14

我认为这可能与类的命名空间和类似的东西有关,但到目前为止我还没弄清楚。

最佳答案

看起来您没有正确注册您的文件夹。我添加了我的代码的简历来给你一个想法。

文件 index.php

use Phalcon\Mvc\Micro;
use Phalcon\Events\Manager as EventsManager;

define('APP_DIR', dirname(__DIR__) .'/');

try {
$config = require APP_DIR .'config/config.php';
require APP_DIR .'config/loader.php';
...
} catch (Exception $e) {}

文件 config.php

return new Phalcon\Config([

'application' => [
'environment' => 'development',
'controllers' => APP_DIR .'controllers/',
'library' => APP_DIR .'library/',
'models' => APP_DIR .'models/',
'plugins' => APP_DIR .'plugins/',
'routes' => APP_DIR .'routes/',
'logs' => APP_DIR .'logs/',
'base_uri' => '/',
'debug' => false
]
]);

文件 loader.php

<?php

$loader = new \Phalcon\Loader;

// Register directories
$loader->registerDirs([
$config->application->controllers,
$config->application->library,
$config->application->models,
$config->application->plugins,
])->register();

// Composer autoloader
require_once APP_DIR .'vendor/autoload.php';

这应该解析配置文件夹中指定的任何类。

关于php - 在 Phalcon 2 中找不到类用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36188800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com