Http\Client on cake3.4

I’ve added the http client call to a new controller and I feel like I’ve fallen at the most basic hurdle. I get this error from the code underneath it. Where have I gone wrong?

**Error:**  Class Cake\Http\Client\Request contains 11 abstract methods and must therefore be declared abstract or implement the remaining methods (Psr\Http\Message\MessageInterface::getProtocolVersion, Psr\Http\Message\MessageInterface::withProtocolVersion, Psr\Http\Message\MessageInterface::getHeaders, ...)
**File**  /var/www/
**Line:**  254
namespace App\Controller;
use App\Controller\AppController;
use Cake\Http\Client;

class AdlistingsController extends AppController {

    public function index() {
        $http = new Client();
// use a nothing page that's quick to "get"
        $response = $http->get('');

I’ve tried you code and it works fine.

This really looks like some problem with your core cake installation. Can you give more information about how you got to this point?

Is this a ‘known’ app that has been working or the first code in a new app?

What version of cake are you working with? [I see, 3.4 my test was on 4.current. But my guess about the source of your problem stands]

By the way, thanks for pointing me to a class I hadn’t looked at yet! This will be useful

It’s a “known app”, an old site which was upgraded from cake1 to cake3 in 2014.

The admin part is on cake2 and I could run these functions through the admin, I’m more comfortable with that version, I really haven’t liked the changes there. It just seems odd that the most basic request falls over.

Hmm… Well, the error is something you don’t control. That’s why I believe it is some ‘partial’ install problem. Like some class that is suppose to implement those 11 abstract methods is not available to do its job.

The problem with this theory is, there doesn’t seem to be a ‘file couldn’t be found’ message and if a missing file WAS causing this, I’d expect that evidence.

Have you looked at the core directory to verify any of the expected structure is there? One way to go would be to bake a brand new project of the same version, then visually confirm the existence of src/Http directory content.

A new, clean app would also give you a second place to try your code and see if it works. I would expect success if it is just an install problem of some kind.

One other thing.

Is there a stacktrace with the error? This would let you confirm that the error is in a logic-path that includes your code.

It probably is, but you never know!