user3753202
user3753202

Reputation: 525

Doubts about require and require-dev of Composer

I'm setting a composer-installable repository. I read the Composer documentation and I setup my repository with success following the instructions. What I understood of the difference between require and require-dev was that the require-dev is for declare dependencies that aren't mandatory for that the repository works properly.

However, I watched the composer.json of some libraries on Github, like Zend Form and Respect Validation, and, on these two repositories, there are packages that are required to that these repositories works properly and are listed in require-dev. For example, the egulias/email-validator dependency is listed in require-dev in Respect Validation, but on this file, this dependency is required in order that Email Validator works. So, why this dependency isn't listed in require?

The same happens with zendframework/zend-captcha, required for that the Captcha element works.

Upvotes: 0

Views: 100

Answers (1)

Federkun
Federkun

Reputation: 36924

this dependency is required in order that Email Validator works.

It isn't. You can see that Respect\Validation\Rules\Email has an optional dependency to Egulias\EmailValidator\EmailValidator. If the egulias/email-validator is provided, then the class will use it, otherwise it will fallback to filter_var. The class will works either way. What the package can do is suggest you to install it.

Upvotes: 1

Related Questions