Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'Laminas\Http\Client' not found #15

Closed
benjaminkohl opened this issue Feb 14, 2020 · 5 comments
Closed

Class 'Laminas\Http\Client' not found #15

benjaminkohl opened this issue Feb 14, 2020 · 5 comments
Labels
Question Further information is requested

Comments

@benjaminkohl
Copy link

Bug Report

I tried to run Reader::import($url) and there appears to be an issue locating a class from within that class.

Q A
Version(s) 2.12.0

Summary

Here is the stack trace. I swapped out the true paths, class names and the URL to protect our client's privacy.

Exception 'Error' with message 'Class 'Laminas\Http\Client' not found'

in /path/to/site/vendor/laminas/laminas-feed/src/Reader/Reader.php:143

Stack trace:
#0 /path/to/site/vendor/laminas/laminas-feed/src/Reader/Reader.php(200): Laminas\Feed\Reader\Reader::getHttpClient()
#1 /path/to/site/modules/clientname/services/Feed.php(64): Laminas\Feed\Reader\Reader::import('https://example.com...')
#2 /path/to/site/modules/clientname/controllers/console/FeedController.php(33): modules\clientname\services\Feed->importPressReleases()
...

Current behavior

See the stack trace.

How to reproduce

I placed the following at the top of my class:

use Laminas\Feed\Reader\Reader;

In a function, I am calling import like:

$feed = Reader::import($url);

That line with "import" is #1 in the stack trace.

Expected behavior

No exception? Feed is parsed and stored in the $feed variable.

@benjaminkohl
Copy link
Author

Disregard. I found my answer after the basic usage code block in the docs. So I installed the laminas/laminas-http package and that works.

@froschdesign
Copy link
Member

@benjaminkohl
If you want to import a feed via a URI, you need an HTTP client. Other options for an import are a string and a file therefore the HTTP client is only a soft dependency.
You must install an HTTP client yourself.

Please see also in documentation for this notice:

Importing requires an HTTP client

To import a feed, you will need to have an HTTP client available.

https://docs.laminas.dev/laminas-feed/reader/#importing-feeds

The "suggest" section in the Composer file also contains this note:

"laminas/laminas-http": "Laminas\\Http for PubSubHubbub, and optionally for use with Laminas\\Feed\\Reader",

@froschdesign froschdesign added the Question Further information is requested label Feb 14, 2020
@froschdesign
Copy link
Member

But thanks anyway, because your request helps us to rethink the error message and provide better help.

@benjaminkohl
Copy link
Author

Yes, thank you. I probably wouldn't have run into this if that block about the HTTP client appeared above the basic usage code in the documentation.

@froschdesign
Copy link
Member

Good point! 👍

Currently I'm working on a description to include laminas-feed in laminas-mvc application. After this I planned a restructuring of the entire component documentation which included a smaller and clearer quick start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants