Composer Tutorial Part 1 - How to use Composer

Composer Tutorial Part 1 – How to use Composer

I take you through basics of using Composer. I explain the difference between a composer.json and a composer.lock file and help you install your first package.

☕️ You can buy me a coffee by supporting this video on Patreon:

😊You can find me here:
My site:

1 – What is Composer – 0:05
2 – Why do we need Composer – 0:29
3 – Getting Started – 1:07
4 – composer.json and composer.lock – 02:05
5 – Composer Install – 04:04
6 – Composer Update – 05:56
7 – Installing our first package – 07:07
8 – Links – 10:12

Composer –
Packagist –

30 thoughts on “Composer Tutorial Part 1 – How to use Composer

  1. ☕️ You can buy me a coffee by supporting this video on Patreon:

  2. I need to do this by using PHP and composer and this is the task, so what does this mean and how am I suppose to do it?
    Sorry I never programmed in PHP or used Composer before, Can u help?

    *The task

    [The aim is is implement the source code link to pass the pre written tests.

    To run the tests run ./vendor/bin/phpunit and look at the output.

    The toInt function should be able to translate any Roman Numerial to the correct integer.

    For example VI should return 6 and XX should return 20

    Cant get phpunit running ?

    Included is an index file (index.php) This should run on any web server (eg MAMP, XAMP etc)]

    *and this is what the source code looks like!


    namespace PhpNwSykes;

    class RomanNumeral


    protected $symbols = [

    1000 => 'M',

    500 => 'D',

    100 => 'C',

    50 => 'L',

    10 => 'X',

    5 => 'V',

    1 => 'I',


    protected $numeral;

    public function __construct(string $romanNumeral)


    $this->numeral = $romanNumeral;



    * Converts a roman numeral such as 'X' to a number, 10


    * @throws InvalidNumeral on failure (when a numeral is invalid)


    public function toInt():int


    $total = 0;

    return $total;



    and this is the link to the actual exercise if you want to see for yourself! :0

    and this is the link to that actual source code! :0

    *Please feel free to copy and paste the links into your browser instead, for your safety if you want!

  3. i got composer installed on my local pc but how can i use it to update my website on a host server? how can i access ftp directory with it?

  4. : If you try installing a package and composer first checks the lock file and finds the package listed in there, why would it then be "installed"?
    Doesn't the presence of the package in the lock file mean it was previously installed?

  5. I have downloaded composer for the purposes of reading xlsx files. I have watched a couple of tutorials to enable me to use the data within a mysql database.

    I have composer installed and ready to go but cannot get any further. Do you have, or are you considering doing a tutorial on reading from an xlsx file? Thanks

  6. this feels a lot like npm for javascript projects. so where can learn more about packages available through composer?

  7. It's always easy to pull package for a new project but way too hard for adding one with old and existing projects

  8. Need lesson/tip on using composer for an old project. I faced a lot of issues with composer if the project/website is old and need to install a new plugin. Dependencies never seems to met and it makes impossible to add new plugin. Sometimes old plugins aren't available anymore and I am forced to use newer ones for which I have no idea how to make sure to get right packages and update the older ones.

  9. Thank you Reval! I have looked for DAYS for an example of what it actually looks like to install a package using Composer, seeing what is going on. This embodies the detail of the relationship between the local server, composer, what the hierarchy looks like after it's installed, WHERE to install it in the first place! THANK YOU. Excellent work!! You kept it to a bare-bones example that provides such valuable clarity for a newbie. Thoughtful presentation, greatly greatly appreciated!!! You a-b-s-o-l-u-t-e-l-y ROCK!

  10. Just watched first composer video. As someone who kept looking at composer and having it fly right over their head a few times, this was really good. It actually went to the necessary level of detail instead of assuming users having familiarity with miscellaneous subtle details that are often left out.

  11. Great video tutorial but many work on hosts. Setting up a localhost using XAMPP or WAMP and using Composer is a lot of unnecessary BS when you can usually just add one line of code to include a library. Composer is some sort of weird cult. Anyone who really needs Composer is probably facing dependency hell.

  12. in wamp localhost when i use via cmd then composer not work but use php strom terminal then work perfectly. what is reason?

  13. I've got a shared hosting service for my website, so I don't have access to WHM and can't run commands like you did.
    Can I still use composer?

Leave a Reply

Your email address will not be published. Required fields are marked *