Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
Do I have to use init before require in composer?

I am bit confused about commands composer init' and composer require

If I am correct:

  • If I would like to add a library to my project from packagist I need to use require
  • If I would like to publish my library to packagist I need to use init

I have a project and I do NOT want to publish it to https://packagist.org/

I just want to add some libraries to my project.

Do I have to necessarily run composer init before I run composer require?

I watched a tutorial, where they use composer init command before calling composer require, which confused me, because I though that composer init was related to publishing a library on packagist.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

composer init just creates an "empty" composer.json, asking you some questions to fill out boilerplate.

No, it's not a necessary command "to publish a package", just a helper to initialize a project. That project can either be an package or stand-alone project.

require adds a package to an existing composer.json, and if the composer.json file does not exist in that directory it will just creates a blank one for you.

So calling composer init is certainly not required before running composer require package-name, but it simply helps you have a more fleshed out composer.json to start with.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!