发生错误 "Class 'HttpSocket' Not Found"

An error "Class 'HttpSocket' Not Found" occured

我正在尝试将 CakePHP 从 ver.1.3 更新到 2.6。

我发现使用 MyLibraryClass 时出错。

错误是:

"Class 'HttpSocket' Not Found"

代码为:

<?php

class MyApiClient {

    public function __construct() {
        $this->socket = new HttpSocket();

所以我在class之前添加了这一行。

<?php
App::uses('HttpSocket', 'Network/Http');

class MyApiClient {

但仍然显示错误。 有没有人处理过这个案子?

根据我们在评论中的讨论,您在 app/Lib

中添加了以下代码
App::uses('HttpSocket', 'Network/Http');

因此,请在 class 定义之前将其放入所需的控制器中。