简体   繁体   中英

Class Amp non found

I'm new on amphp and i'd like to try this very simple code first. I downloaded amphp with composer for windows and save all folder created inside my project folder.

composer require amphp/http-client

Then my code is:

<?php

require __DIR__ . './autoload.php';

use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\HttpException;
use Amp\Http\Client\Request;
use Amp\Http\Client\Response;
use Amp\Loop;

$stringa = 'http://www.google.it/';

$request = new Request($stringa, "GET");
$location = $request->getHeader("Location");

var_dump($location);

But I get always 'Fatal error: Uncaught Error: Class 'Amp\Http\Client\Request' not found'

Any suggest?

I use wamp local server with php 7.0

Also,after, I need to yield all the code...

Here are a few things that look for:

  • Did the autoload.php get included correctly?
    • I see there is an unnecessary . before /autoload.php .
  • Did you use the correct class name with the correct namespace?
  • Did you run composer require amphp/http-client so that the libraries will be installed?
  • Do the library's files exist inside the vendor/amphp/http-client directory?
  • If you're on Windows, use \ in the require statement.

Apart from these, I can't think of why the library won't load. I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM