Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shiva's avatar
Level 5

Adding a require to composer

I know that the title might be a bit wrong, but I couldn't think of a better title. I'm learning to create a package and I've gotten to a section where I'm not sure if I missed something. In my usual laravel app I would put

"caffeinated/modules": "^4.0"

in my composer.json. But when I created my composer.json for my package I added the "caffeinated/modules" : "^4.0".

What I would like to know is how do I add "caffeinated/modules" : "^4.0" to the main composer.json.

I hope I made sense there.

0 likes
2 replies
WebKenth's avatar
WebKenth
Best Answer
Level 16

if you added it to the Packagist Repository you could do the following

composer require caffeinated/modules=^4.0

or just manually add it in the main composer.json file and run composer update?

If it's set to readonly just change the permissions on the file

Shiva's avatar
Level 5

I will do that. Thank you.

Please or to participate in this conversation.