What is composer?

October 1, 2017 By - Usama Muneer | 135

    If you’re a PHP developer and has been coding up for years, you may have noticed that while developing in PHP, you have to re-invent the wheel every single time. You have to re-write several modules over and over again. You have to include and require your files every single time. Composer is basically the solution to all of these problems.

    What’s Composer?

    Composer is a dependency manager for PHP. Composer will handle all the dependencies required in your application by pulling in all the required libraries and extensions and manage them in one place.

    Composer is for PHP as NPM is for JavaScript. Composer was inspired by NPM from NodeJS and Bundler From Ruby.

    Using Composer

    You can use composer in your PHP project by simply init composer in your project.

    $ composer init

    This command will get you through the basic configurations for your application, such as

    • Package Name
    • Description
    • Author
    • Minimum Stability
    • Package Type
    • License

    This will generate a composer.json file for you. You can then run:

    $ composer install

    to generate composer.lock and vendor directory.

    Well, that’s it. you are all set to go.

    More Readings

    blog user
    Usama Muneer

    A web enthusiastic, self-motivated & detail-oriented professional Full-Stack Web Developer from Karachi, Pakistan with experience in developing applications using JavaScript, WordPress & Laravel specifically. Loves to write on different web technologies with an equally useful skill to make some sense out of it.

    Related Posts

    In this article, we'll go through a brief introduction on setting up PSR4 Autoloading using Composer within your project.

    Manually Installing composer is an advanced technique, however there are several reasons why a developer might prefer this reason instead of using the interactive installation routine.

    Over the years, Laravel has brought so much excitement in developing applications with its out of the box code-base

    Working with Laravel is amazing it feels magical but sometimes you get stuck in those magics Laravel is doing for you behind the scene.