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

laminas/laminas-diactoros is under require-dev #40

Closed
mtownsend5512 opened this issue Apr 5, 2021 · 10 comments
Closed

laminas/laminas-diactoros is under require-dev #40

mtownsend5512 opened this issue Apr 5, 2021 · 10 comments
Assignees

Comments

@mtownsend5512
Copy link

Trying to utilize this package but I get the error:

Class 'Laminas\Diactoros\StreamFactory' not found

I looked at the composer.json file and you have laminas/laminas-diactoros under require-dev. Shouldn't it be included under the require key if it's a package dependency?

@meng-tian
Copy link
Owner

meng-tian commented Apr 7, 2021

Hi Mark,

The latest release this package no longer requires laminas/laminas-diactoros as a hard dependency. Instead, this package now depends on PSR-7 and PSR-17 interfaces, so the clients of this package need to decide which implementation of PSR-7/17 they want to use (e.g., laminas/laminas-diactoros), install the implementation as a dependency, and inject the dependencies.

Where that error comes from? If you can give me the location (i.e., file and line) of that error, I can probably try to reproduce.

Thank you.

@meng-tian meng-tian self-assigned this Apr 7, 2021
@meng-tian
Copy link
Owner

Closing this issue due to inactivity.

@boryn
Copy link

boryn commented Jan 16, 2022

Hi @meng-tian!

laminas-diactoros is used in the README.md as na example. How to use your library without laminas-diactoros?

What should be passed as a second and third parameter to the $factory->create() if we don't want to use laminas-diactoros?

PS. When I ran composer require laminas/laminas-diactoros, the code started but if laminas-diactoros is not obligatory, the question is how to use the library without it?

@meng-tian
Copy link
Owner

meng-tian commented Jan 17, 2022

What should be passed as a second and third parameter to the $factory->create() if we don't want to use laminas-diactoros?

The example in README does use laminas-diactoros, but that does not mean it has to be laminas-diactoros. Any implementation of Psr\Http\Message\StreamFactoryInterface and Psr\Http\Message\RequestFactoryInterface can be passed to the second and third parameter of $factory->create(). You can find many other implementations from here.

Again, I want to reiterate that laminas-diactoros isn't a hard dependency for this library anymore. It is used only as a development dependency because unit tests use it, but unit tests can use other implementations of PSR as well.

@boryn
Copy link

boryn commented Jan 18, 2022

Previously we used "^0.2.5" and there was no need for these two new parameters.

IMHO the example in README should just work upon installation. If there is a need for implementation of Stream/Factory it should be mentioned and explained in short what it does and why it's needed.

(Or maybe these two new parameters could be passed even as nulls?)

@meng-tian
Copy link
Owner

(Or maybe these two new parameters could be passed even as nulls?)

No, the second and third parameters must be not null.

IMHO the example in README should just work upon installation. If there is a need for implementation of Stream/Factory it should be mentioned and explained in short what it does and why it's needed.

Well, it kind of self-explanatory. Both those two parameters require an instance of the interface. This naturally implies that an implementation of the interface is needed. You cannot instantiate an interface in PHP, so you have to instantiate a implementation of the interface instead.

Not having a hard dependency on a specific implementation (e.g., laminas-diactoros ) makes this library flexible to meet when users are. Different users could choose their own preferred implementations, rather than being forced to use one specific implementation.

@coopan
Copy link

coopan commented Dec 13, 2022

I have to agree that the usage of the lib is rather confusing now. It has required parameters for its actual setup, but no implementation details of what those two parameters are in practical terms. The Readme compounds confusion as it's showing a constructor based on a library that is not packaged with this library without any notes or info.

I appreciate the option of flexibility, but almost all libraries that require a certain type of dependency to be passed into its own constructor include the dependency lib in it's composer.json, or provide instructions on where/what those objects are.

We too are doing a migration from 0.2.x to 0.4.x and it's still not obvious to me what the two new parameters are in code. I'm assuming we need to create two new classes that implement psr/http-factory interfaces just to use this library. Which I will try next. But I can't say I've had to do any trial and error just to instantiate the primary class in a project. I few sentences on this in the readme will probably eliminate what's been typed in here.

@meng-tian
Copy link
Owner

meng-tian commented Dec 14, 2022

I'll try address the confusion by updating the README to give clearer explanation on how v4.0+ should be installed and used.

I'll try my best to finish #43 within this week.

@meng-tian
Copy link
Owner

#43 is now resolved. Let me know if the usage and installation is clearer than before.

@coopan
Copy link

coopan commented Dec 18, 2022

Thanks @meng-tian!

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

No branches or pull requests

4 participants