Sharon
Sharon

Reputation: 3919

CakePHP: "Class 'HttpSocket' not found"

I'm trying to use CakePHP's HttpSocket class to make an API call, but I can't seem to get it to include the class. It seems pretty simple, so I can't see where I might be going wrong, but here's what I have:

At the top of the controller:

class RetailersController extends AppController {

    public $uses = array(...lots of classes..., 'HttpSocket', 'Network/Http');

Then in the function itself:

$HttpSocket = new HttpSocket();

And when I run that, I get:

Fatal Error

Error: Class 'HttpSocket' not found

As I said, there's not much to this, so I can't see that there's much that can go wrong - but I seem to have managed it! What can I try next?

I'm using CakePHP 2.4.

Upvotes: 2

Views: 1255

Answers (1)

skywalker
skywalker

Reputation: 826

Add this before class definition:

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

This variable is only for models: $uses

Upvotes: 5

Related Questions