Create your first ever PHP Packagist for Composer Part 1

Andino Inyang
Backend Developers
Published in
3 min readSep 27, 2019
Packagist is a default composer repository

I recently started my journey of contributing to open source. Contributing to the open-source community is now a big deal in the tech industry, every junior developer, and an intermediate like myself is expected to venture in. Employers now demand my Github repo shared with them, more than ever. Building libraries that can be used by others is a cool way to start I thought to myself. However, I have been questioning myself about building libraries for other PHP developers (especially with multiple frameworks in consideration). Questions like What happens when every library I build needs to be bootstrapped? Would ```git clone``` do the trick? What happens when people need the library in different projects? Packagist solves all these. We are going to look closely to the key terms before shortly before I dive into the deal of the day.

So What’s a Composer??

According to the Official Composer website, Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. In simple English Composer is a dependency management tool for PHP, composer replaces the old use of PEAR (PHP Extension Application Repository).

What’s Packagist??

Packagist is the default Composer package repository. It lets you find packages and lets Composer know where to get the code from. You can use Composer to manage your project or libraries’ dependencies. A package is connected to a GitHub repo and is made available via composer.

Starting Composer

You can start composer running the ```composer init``` in your project root. However, in this section, we would explore creating composer manually from the file system. Create a ```composer.json``` from your project root.

Above is a simple composer.json file

What Next?

Now that you have created composer in your project root follow these steps below.

  1. Create a Github repo for your package, initialize it locally and push to the remote origin.
  2. Submit your package

Now your package is online and ready for use. Your package can be added to PHP project via the composer command

`composer require username/package-name.`

You should connect your package to your Github repo so it syncs on every update.

Conclusion

This not the end of this series. Stay tuned, and follow me for more of this series and other interesting articles.

Thank you for reading my article and my editor Solomon Eseme. Here at my blog or medium I regularly write about backend development, digital marketing and content management system. To read my future posts simply join my publication or click ‘Follow’ Also feel free to connect with me via Twitter, Facebook, Instagram.

If you are interested in backend development (or you’re internet enthusiast) both (Mobile | Web | Desktop) videos subscribe to my Youtube channel, we will be posting a collection of help full tutorials and guides like this one for artisans.

If you enjoy this post, make sure to let us know and share it with your friends and subscribe to my growing channel.

Sharing is caring.

--

--

Andino Inyang
Backend Developers

Experienced Product Analyst skilled in market research, experiment management, strategy development, and cross-functional collaboration.