Package Managers: What are They and How are They Useful to Us?
“Package Managers” are not new; but an year ago, we were not using them. It was kind of an strange idea to us. But now we love them. This is the story of us at Sanmark adopting a couple of package managers and learning to love them!
A Change in the Operating System
In our beginning, Microsoft Windows was the only operating system used in the office. But that changed when I introduced Ubuntu to Kosala, our CEO. At the start, he was a little bit confused about doing things in Ubuntu, but he learned very quickly. He liked it so much so that he wanted to use Ubuntu as our “official operating system”.
Using that, our team soon had to realize installing — and updating, and removing — software doesn’t necessarily mean “Download. Double-click. Next. Next. I agree. Next. Next. Finish.”. Application software become parts of the OS itself, instead of things we forcibly make the OS co-operate with. We ask the OS to find, download, and install any software we want, and that’s it. OS will then go and find that software, check whether that needs any more software to work with (“dependencies”), download it with any dependencies, along with dependencies of dependencies and so on, and finally install the thing for us.
This was a huge change compared to Microsoft Windows we used to use, and I had a hard time explaining the advantages of this method over that of Windows.
A Change in the Framework
Last year we also started using Laravel as our PHP application development framework. This utilizes the PHP package manager “Composer”. Composer allows you to prepare a list of PHP Packages needed for your web application. Once done, Composer can download and install those packages in your application.
Composer is the second package manager that we got to work with.
A Change in the Frontend
Another thing we did in the last year is adopting the method of separating our web applications into to two clearly separate parts: the back-end (API) and the front-end (App). As mentioned above, Laravel became our API building framework. For the front-end, we chose AngularJS from the web-giant Google.
Can I not Use Package Managers?
Without asking Ubuntu’s package manager “apt-get”, you can browse Ubuntu’s package repositories manually through your web browser and download them. However, you will have to deal with identifying each package’s dependencies and downloading them as well.
Once you download them, you can use application “dpkg” to install them. But I am sorry to say that is more likely than not this process will fail.
Composer downloads the packages into your PHP application’s “vendors” directory. You can easily browse the web — Packagist and GitHub will be your favourite sources — for PHP packages, download them and put them in your “vendors” directory. You will have to check whether those packages have dependencies as well, because for them to work, they will need those dependencies installed.
What are Package Managers then?
Package managers helps you find, install, keep them up-to-date, and remove any third-party packages on your Operating System or applications. They allow you to worry only about your OS or application, and they work to keep the third-party stuff managed.
What are Dependencies?
Each third-party package is an application on their own, just like the one you are creating. They might be using other third-party packages to get their work done. They are called “dependencies” because the package you need installed depends on these other packages.
Why do We Love Package Managers?
They make us feel super cool. 😀 No, really. We don’t have to upload a whole bunch of third party packages each time we deploy a web application. We just upload our own code along with a list of needed third party packages, and ask the package manager to download those stuff and get them installed. And that works like a charm. We avoid accidentally forgetting to upload some package because the only thing we have to upload is a little text file.
Apart from that, we can easily run “update” command to see whether any of our third party packages has new versions out there. Imagine trying to update third party packages in a half-a-dozen places manually. It’ll be a mess!
Package managers are cool and makes your work flow so much easier. They allow you to focus on your own code, rather than trying to keep up with some others’ packages. They make you so efficient!