在 Concrete5 主题中包含自定义 class

Including a custom class in Concrete5 theme

我正在学习 Concrete5 和 运行 以解决让我感到困惑的问题,但似乎应该很容易解决。

我的 class(位于 \application\src\Derp\Derp.php):

namespace Application\Src\Derp;    
use Concrete\Core\Database\Connection\Connection;

class Derp
{   
    return 'Hello';
}

我从主题中的页面调用它,如下所示:

use Application\Src\Derp;
$derp = new Derp();
var_dump($derp);

我不断收到 'An Unexpected Error Occurred'。 Class 'Application\Src\Derp\Derp' 未找到。我错过了什么?

您应该一直引用到 class 的路径。 所以试试

use Application\Src\Derp\Derp;