DEV Community

Cover image for Setup from scratch your new MacBook for Development
Roberto B.
Roberto B.

Posted on • Edited on

Setup from scratch your new MacBook for Development

Today, I received my new MacBook, and I started to install applications and software for local development.
My typical development stack is based on PHP and JavaScript, but I'm learning also Go Lang and Rust.

I'm a macOS user for a decade, and I have my software list, but starting from scratch, allows me to ask myself if I should review my software list. For example, at the very beginning, I used Terminal.app as a console application, then I switched to iTerm2 (and it is great), but I would like to investigate if it is still the best option, today in 2022.

I would like to share the first applications or the first steps that I made with my new MacBook.

Table Of Contents

Upgrade the Operating System

In "System Preferences" there is the section "Software Update".
Be sure that your Operating System is updated.

Update macOS

Install Brave Browser

This is a personal choice. Someone prefers Safari, someone else prefers Mozilla Firefox. Personally, I used Chrome just because I'm more familiar with the "Developer Tools".
In the latest weeks, I'm trying Brave because it is designed to respect the privacy of the end user. Under the hood it uses Chromium, so the same engine as Google Chrome.

Website: https://brave.com/

Install HomeBrew

My suggestion is to install it as soon as possible Homebrew, because it helps with some dependencies (for example it installs automatically Xcode Command Line tools).
Xcode Command Line tools are the most-needed utilities for software development.
And it is very useful later for installing PHP and some other tools like web server etc.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

The execution of the command will prompt for the administrator password. You need to insert your password.

Once you installed Homebrew you need to configure correctly environment variables:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
Enter fullscreen mode Exit fullscreen mode

Website: https://brew.sh/

If you need some "inspiration" about which packages/applications you would like to add to your new Macbook, James suggested me take a look at his Brewfile. So I'm going to share it with you all as well https://github.com/jwtodd/miscellany/blob/develop/Brewfile
Reference: https://twitter.com/jwtodd/status/1531529092998176768

Install Git

The first package I installed with HomeBrew is Git. Why? Git is already included in Xcode Command Line Tools but I prefer to have installed the Git shipped with HomeBrew, it is most updated. This is a personal choice, but if you want to have Git command continuously updated, probably you could consider installing the HomeBrew version

brew install git
Enter fullscreen mode Exit fullscreen mode

Install a new Terminal: Warp

For the console app, in my previous MacBook, I used iTerm2. It is a great application, but some Twitter friend of mine suggested Warp.

So I decided to try and install Warp.

Warp Terminal

Website: https://www.warp.dev/

Shell extension: Install Oh My Zsh

Probably if you are using a fresh new installation of macOS Monterey (12), you have zsh as default shell application. There is a great project named Oh My Zsh that extends the functionalities of zsh providing some functions, helpers, and configurations.

To install Oh My Zsh:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Website: https://ohmyz.sh/

The editor: Visual Studio Code

One of the most popular editors is Visual Studio Code.

Website: https://code.visualstudio.com/

The Font: JetBrains Mono

I suggest you download and install a Font Fixed Width like https://www.jetbrains.com/lp/mono/

Jumping back to the Visual Studio Code configuration, my typical setup for fonts is:

{
    "workbench.colorTheme": "Default Light+",
    "editor.fontFamily": "JetBrains Mono, Menlo, Monaco, 'Courier New', monospace",
    "editor.fontSize": 18,
    "editor.lineHeight": 1.6
}
Enter fullscreen mode Exit fullscreen mode

Website: https://www.jetbrains.com/lp/mono/

Install Node via NVM

Typically, I use a Node Version Manager to install multiple versions of Node. Because in some projects you need Node 16, in some others Node 14, and so on.
To install NVM (the version manager):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Now, once you have the version manager, you have to reload the shell, and then you can install the latest version of Node:

nvm install node
Enter fullscreen mode Exit fullscreen mode

Now, you can use your latest version of Node.

Node Version

Website: https://github.com/nvm-sh/nvm

Install PHP 8.1 via Homebrew

My suggestion is to install PHP via Homebrew, because Homebrew is great for managing dependencies needed by PHP, and useful for example if you want to install a PHP module. Installing PHP via brew command:

brew install php
Enter fullscreen mode Exit fullscreen mode

It will install the latest version of PHP (8.1) with some dependencies like: apr, ca-certificates, openssl, apr-util, argon2, aspell, m4, autoconf, brotli, gettext, libunistring, libidn2, libnghttp2, libssh2, openldap, rtmpdump, zstd, curl, libtool, unixodbc, freetds, libpng, freetype, fontconfig, jpeg, giflib, imath, openexr, libtiff, webp, jpeg-xl, libvmaf, aom, libavif, gd, gmp, icu4c, krb5, libpq, libsodium, libzip, oniguruma, pcre2, readline, sqlite and tidy-html5.

The PHP module (for Apache) is located in: /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

The ini files for PHP are located in:
/opt/homebrew/etc/php/8.1/

PHP 8.1

Website: https://www.php.net/

PHP Package manager: Composer

I suggest you to install the "standard de facto" package manager for PHP named Composer. My suggestion is to install it globally, in a global directory.

If you copy composer binary into /usr/local/bin remember to:

  • check if bin directory in /usr/local exists (if not created it with
sudo mkdir -p /usr/local/bin
Enter fullscreen mode Exit fullscreen mode
  • move the binary
sudo mv composer.phar /usr/local/bin/composer
Enter fullscreen mode Exit fullscreen mode
  • add /usr/local/bin in your PATH environment. For example appending in your ~/.zshrc
export PATH=$PATH:/usr/local/bin/
Enter fullscreen mode Exit fullscreen mode

Serving your Web projects with Valet

If you are a Web Developer, probably you have multiple projects on your local machine, and you want to expose them via HTTP, for example:

To achieve that, you need to configure correctly a web server (Nginx) and a tool for resolving your local hostnames (dnsmasq).
Valet is a tool that can do all this stuff for us.

Valet configure and install tools for you, like:

  • Webserver: Nginx for serving files
  • PHP / PHP-FPM: you already have installed PHP from previous steps but Valet will configure PHP to be used with Nginx via FPM
  • Dnsmasq: for resolving locally your local domains name *.test (project1.test, project2.test etc)
composer global require laravel/valet
export PATH=$PATH:~/.composer/vendor/bin
valet install
Enter fullscreen mode Exit fullscreen mode

Now you can instruct Valet for serving all directories included in a specific directory. In my case I have Sites directory where I have all my projects

mkdir Sites
cd Sites/
valet park
Enter fullscreen mode Exit fullscreen mode

Valet

So, if you will have a directory Sites/mysite , thanks to Valet (that will use dnsmasq and nginx under the hood) a hostname http://mysite.test will be exposed locally.

Valet is more powerful than this, you can expose HTTPS, you can be more flexible in the configuration of your directory (not limited to the Sites directory) etc.

Website: https://laravel.com/docs/9.x/valet

Managing Git repositories: GitHub Desktop

I'm mainly using GitHub for my side open source projects.
I'm using git on the command line. But sometimes I would like to have a GUI for some operations. In the past (so far away) I used GitX, in the last 2 years I'm using GitHub Desktop (but you can use it with git repository in general, like Gitlab or Bitbucket).

Website: https://desktop.github.com/

Feedback

I know, this is just a first, initial list of a wider set of tools that a developer needs. But if you think that I missed some very important tools, please let me know in the comment!
I will be super happy to try it and add them to this list.

Thank you!

Top comments (3)

Collapse
 
lksmrqrdt profile image
Lukas Marquardt • Edited

Warp is a great terminal emulator and clicked with me way better, than iTerm2! My only deviation from this list is, that I use GitKraken as Git GUI.

GitHub Desktop always seemed a bit dated and Tower just isn't as intuitive to use IMHO.

Collapse
 
fathuraw profile image
Fathur Rachman Widhiantoko

personally I choose iTerm2 over warp.

Also don't forget fig

Collapse
 
timlar profile image
Dmytro Hrechukha

I would also recommend to take a look on the Kitty terminal and asdf as a version manager.