简体   繁体   中英

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.

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.

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