How to install a package manager for macOS
LiteBreeze believes that the best quality work machines are a supplement to sustain the high work standards of our ever growing PHP team.
That is why the MacBook is the LiteBreeze choice of work machine as MacBooks maintain a proven standard and offer better performance over standard laptops.
Recently the LiteBreeze team began migrating to MacBooks. For some of us, this migration from Windows/Linux platforms to macOS was slightly challenging as the macOS ecosystem looks peripherally a lot different from our Linux/Windows environments.
For example, Windows and Linux(more or less) lack the concept of installing applications through an App Store whereas macOS seems to rely heavily on the App Store to install any app.
For longtime Linux users, I am sure that when they use macOS for the first time, they will miss package managers like aptitude and yum.
In fact, as a wise man once said, the first impression may not be the right impression. With a few manual configurations, the macOS enables you to get things done much faster than the other environments.
This article series intends to give the reader a brief configuration walkthrough of the development environment on macOS for PHP/Web developers.
In this post, I will focuss on installing Homebrew, the package manager for macOS
1. Setting up the package manager(Homebrew).
Homebrew is a package manager for the macOS to search, install and configure software packages and libraries through the command line. It simplifies the package installation by automatically finding and installing the dependencies when you are installing a package.
To install homebrew, first, we need to install the Command Line Tools for Xcode. This package includes the compilers that are required to build packages from their source. To download the command line tools go to downloads and log in with your Apple ID.
If you do not have an Apple ID, create one at this link. Once you have logged in, download the command line tools package that matches your macOS version. Open the .dmg file once the download is completed and double click on the .pkg file to launch the installer.
Once you have completed the installation, we can proceed to Homebrew installation. For this, open a terminal and copy paste the following command(exclude the $ sign).
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Hit enter and follow the prompts on the terminal. Once this step has been completed, we need to tell macOS where Homebrew will install the packages. For this, run the following command on the terminal.
$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Now, to verify the installation quit and reopen the terminal and run the following command
$ brew doctor
Brew will diagnose the current setup and will show issues and their fixes if any.
Now that we have Homebrew installed on Mac let us move on to its basic usage. In Homebrew terminology, a package is called a ‘Formula.’ To install a package/formula run the following command
$ brew install <formula>
Similarly, to update a package, run
$ brew upgrade <formula>
To uninstall a package, run
$ brew uninstall <formula> $ brew cleanup
To search for a package
$ brew search <formula>
These are just the basic common operations with Homebrew. For those interested, a detailed list of commands can be found here
Note: This blog is the first post of a series and will be followed up with other posts in continuation as time permits.