DEV Community

Cover image for My work setup for PHP development
Ben Sinclair
Ben Sinclair

Posted on

My work setup for PHP development

These days the majority of my (programming) work is (in order of SLOC): PHP, Javascript (including Node), CSS, HTML, and shell scripts. I do sometimes dip into other languages, but the instances are tiny compared to these main ones.

And this is my story.

Hardware

I'm writing this on my main me-facing machine. It's running Windows 11, but that's almost entirely for Important Gaming Reasons.

Work provides me with a MacBook Pro, which I need to use for Important Corporate Reasons such as VPN access, and because it has a nicer video meeting experience. But really, I just shell into it and use it as a docker host and network proxy. I don't get along with the Apple keyboard, which is a broken mix of UK ISO and US ANSI and feels like typing on a child's toy. I appreciate the touchpad and screen, which are both impressive - but I much prefer using a mouse. So the Mac is relegated to being a third screen on the corner of my desk.

A main in a suit carrying too many plain brown paper bags

It's a mixed bag.

I have a laptop I use if I'm working at the kitchen table, which I occasionally do. It's running ChromeOS though I'll probably swap that out for Linux at some point. "Developer" mode in ChromeOS gives me a command line and shell access, so my workflow with browser/cli is pretty much the same.

Operating system

John Connor in Terminator 2 saying,

Everything I do for work is through Ubuntu under WSL on the Windows 11 desktop, SSH on the ChromeOS laptop or Barrier'd into the MacBook Pro.

I know this sounds impractical. There are weird issues, such as Apple's bug where you can't use an IPv4 address in /etc/hosts for external connections because the firewall blocks it but you can if use IPv6, even if you're not connecting via IPv6. Oh, there were fun times figuring that hack out.

But though decade-ago me would have never thought it, nowadays Windows Subsystem for Linux - specifically WSL2 - is actually pretty decent. You can even run X applications if you install an X server, and there are a bunch of those available.

I don't use X for anything though. If it's not in a browser, I don't tend to care about it, and there's no good reason to use a Linux browser via X compared to a native one.

I can't help feeling a little bit dirty for using Windows, but I cram that feeling way down inside and try to ignore it.

Desktop - Barrier

I don't use this too much any more, but Barrier is a fork of Synergy from before Synergy went closed-source. It bills itself as a kind-of-software-KVM, but what it boils down to is that I can move my mouse between different computers exactly the same as I can between the pair of monitors on my PC. If I move the mouse off the right side of my desktop monitor, it appears on my Macbook, and all mouse and keyboard input are seamlessly transferred there, just as if it was all one glorious whole.

Hashtag #gamechanger.

Terminal - WezTerm

I have only recently started using WezTerm. "Recently" in terminal-speak means in the last year or two, because things move slowly in this world. I don't tend to change unless there's a good reason.

So what was my good reason? What was wrong with Windows Terminal/iTerm 2? Well, WezTerm is cross-platform, and I can share the same configuration - in Lua! - between hosts. It doesn't make weird restrictions (like the way Suckless will never support tabs), and it's very customisable.

As far as customisation goes, it's mostly font, background image and colourscheme. I usually use Gruvbox1 Dark for most things, though I override a couple of bits depending on the context.

But wait. Background image, you ask? On a terminal? Why? Well, it so happens I have a post about that:

Shell - zsh

I settled on zsh because it's the default on Macs. I know, I know: I don't really use the Mac much. But it's almost entirely compatible with bash for all the things I care about, and it's available on all the systems I use.

I try to make every script I write POSIX-compliant, and if I use something that's different between BSD and GNU (like sed -i) I'll wrap it in a condition.

It's fair to say that the choice of shell doesn't really matter much.

So before you say anything, no, I don't use oh-my-zsh. It doesn't offer me anything I care about that I can't do out-the-box with zsh (or bash for that matter).

Oh, and I almost never use aliases, either.

Editor - Neovim

I've been a Vi/Vim user for a long time, but I switched to neovim a year or two ago. I didn't originally see the point in switching, because all the features people went on about in neovim (and they did oh so go on about them! - async, LSPs, embedded terminals, etc.), well, they were either also available in recent versions of Vim or were stuff I really wasn't interested in. Stuff I didn't think belonged in an editor. Stuff that was trying to make Vim into Emacs.

Well, I still think those same grumpy thoughts, but I decided to try out a few of the neovim "distros" just to see what was out there and have ended up sticking with it. When loaded with plugins, it's certainly buggier than Vim, but it's still also a nice and comfortable editor for me - and it has more of a future, especially now Bram is gone (RIP).

Productivity

Tmux

Tmux is, as it's always introduced, a "terminal multiplexer", like GNU screen. It lets you close a terminal session and reopen it without losing your work, and it lets you run multiple terminal sessions at the same time.

The upshot of this is that I can leave my work running on the MacBook and connect from other machines via ssh and, by running tmux attach I am right back in the thick of things. I don't need to open a bunch of sessions each time, or remember what directory I was in or what services were running, it's all just there.

Tmuxinator

The tmuxinator project is a wrapper for tmux, which lets you manage multiple separate tmux sessions.

As an example, here's the list of projects I currently have running on my macbook:

❯ tmuxinator ls
tmuxinator projects:
bc           biascan      ec           fabric       gce          ifpma
leith        leith-2023   msgan        chickenland  ngs          ngs-new
ods          ren          renaissance  scramble     sf           sf-cms
sf-forms     sf-myplans   sgh          srn
Enter fullscreen mode Exit fullscreen mode

What's in these projects? Well... they have a lot of specifics in them, but what they mostly boil down to is similar to this random project I picked as an example:

windows:
  - cms:
    - ddev start
  - storybook:
      panes:
        - watcher:
          - cd web/storybook
          - yarn watch
  - middleware:
    - workon mw8
  - logs:
      panes:
        - cms:
          - workon ngs
          - docker exec -it ngs-cms-php drush -y --uri=ngs-cms.shore.signal.sh -r /shore_site/web ws --tail --full --extended --count=1
        - new-cms:
          - workon ngs-cms-2022
          - docker exec -it ngs-cms-2022-app vendor/drush/drush/drush ws --extended
        - middleware:
          - workon mw8
          - docker exec -it ngs-middleware-app vendor/drush/drush/drush ws --extended
  - build-services:
      panes:
        - new-cms:
          - workon ngs-cms-2022
          - cd web/storybook
          - yarn storybook
Enter fullscreen mode Exit fullscreen mode

In this example, I have tmux windows for a Drupal 7 project, its Drupal 10 rebuild, some shared middleware, the front-end build services, a storybook server and a metric ton of logging.

The ridiculous number of switches and dials in the Concorde cockpit

I can spin this all up with tmuxinator <project name>, and switch between its collection of windows with Ctrl-A <number> and to any number of completely different projects with a pop-up menu I get by hitting Ctrl-A S.

Ddev

Ddev is something that lets you create containerised (docker) environments for projects. It works with PHP and Node and (experimentally) Python.

A small statue of a giraffe standing on a zebra which in turn is standing on an elephant

The thing that manages the stack, basically.

My company used to use a home-grown docker-compose wrapper for this, back when there weren't many options. Ddev is really solid, though, and every time I have to work on a legacy or inherited project I'll convert it to Ddev as soon as I check it out. It doesn't usually take very long, and it means we have a consistent way of working. It makes it incredibly quick and easy to switch between PHP or Node versions, for instance.

Some of its main selling points for me are:

  • Uses Mutagen for the file system, so it's fast even on MacOS (where Docker mounts are notoriously slo-o-ow)
  • Easily lets you reconfigure PHP and Node versions
  • Knows about a bunch of third-party apps - for instance, if you have a database GUI app like TablePlus or DBeaver you can launch it from the command line
  • Supports community-maintained add-ons

and so on. It's good.


Image credits:
"Man Carrrying Groceries" - DodgertonSkillhause
"The Ridiculous Switcherama of the Concorde Cockpit" - Me.
"Statue" - lauramusikanski
"Scene from Terminator 2" - Sorry, I can't hear you I'm going through a tunnel


  1. I pronounce it the way it's spelt. 

Top comments (20)

Collapse
 
sethsandaru profile image
Seth Phat

That sounds like a lot of stuff to me 🥹

I love the minimal setup, I only need to install these: Herd, MySQL, nvm (yes I don't like Docker on my local machine), and TablePlus.

Dev mode: php artisan serve, npm run dev and that's all

Ah yes, count PHPStorm in, everything I need is already included in that awesome IDE.

I have no problem bringing my MacBook anywhere (travel, coffee, etc), can ensure I have at least 9hrs of battery

Collapse
 
arcahyadi profile image
arcahyadi

Same, sounds too much
Php is pretty straightforward kind of languages 😅

Collapse
 
millsoft profile image
Michael M

tableplus

not sure how good tableplus is, but phpstorm has a nice db client included.

Collapse
 
moopet profile image
Ben Sinclair

Tableplus is ok, but it's not free software. I guess neither is PHPStorm :) I prefer to stick to the free side of things.

I use DBeaver for cross-platform database shenanigans with multiple configurations, but tbh if I have command-line access I prefer that.

Collapse
 
sethsandaru profile image
Seth Phat

true, however, tablePlus will come in really handy for managing multiple databases and environments (and I have 10+ different projects).

Super lightweight with cool features, worth the investment :D

Collapse
 
ingosteinke profile image
Ingo Steinke, web developer

I use alternative setups, depending on the project, team, and situation. VSCode (or Codium) is lightweight, still quite powerful, but on my default machine, I use PhpStorm with plugins like PHP Annotations, Shopware, Shopware 6 Toolbox, SonarLint, Symfony Support, many other intergrations for static analysis and code completion are already integrated. My hardware is a Linux Laptop with Ubuntu Budgie, but I also used Linux Mint and a MacBook. I have an external monitor that I can connect if I really need more screen space, but despite focusing on frontend web development, I'm mostly content with my laptop screen.

Collapse
 
jlangz profile image
Jakob Langseth

Thanks for the article! Not a ton of love for PHP setups these days.
I don’t work much with PHP in my job these days, but still tinker to stay up to date.

Any particular reason you went with DDEV over Lando or Docksal for docker management?

Collapse
 
moopet profile image
Ben Sinclair

Nope. I never really researched them, but ddev was the recommended way of running Craft (I think) at the time and we stuck with it.

Collapse
 
alexk profile image
Alex Kaul • Edited

Thanks for sharing your stack!

Another productivity app you might be interested in (especially if you work on multiple projects): Freeter. It allows to organize web apps, files & folders, urls, etc by projects and workflows and stay focused on what matters at any given moment. Free & open-source.

A quick post on how I boosted my productivity with it: dev.to/alexk/how-i-boosted-my-prod...

Collapse
 
moopet profile image
Ben Sinclair

That looks really cool.

It's not for me since I do 99% of my stuff in the terminal anyway, but it's a smart idea. I do sometimes use Ferdium to group together all my different chat/email web clients into one glorious electron whole, though, which is like part of what Freeter seems to do.

Collapse
 
dzelenika profile image
Damir Zelenika

Too complex and too heavy for me. I work on an web development project and all what I use is LTS Ubuntu powered laptop (16 GB RAM and AMD Ryzen 5) with VSCode and few plugins.

Collapse
 
moopet profile image
Ben Sinclair

A few people have mentioned that it's complex.

I'm perfectly fine just using Vim and a browser, I just like to be able to do it easily from wherever I am and to switch between any of the projects I work on quickly.

Collapse
 
fausto_alberto_c7a2695c82 profile image
Fausto Alberto

Great idea the kitchen table, i´ll move my setup to the kitchen, i use to eat a lot when i´m working.

Collapse
 
martinbaun profile image
Martin Baun • Edited

Hi Ben, thanks for sharing! I got a tip to use .editorconfig file, turned out to be a great idea :)

Collapse
 
samandar_abduraxmonov_0ec profile image
Samandar Abduraxmonov

That's cool I have only one laptop with ubuntu, and additional monitor which I don't use most of the cases, the truth is I can't concentrate on two things at the same time.
I guess Ddev is not for me cause Docker would enough for me. I have used many OS systems and I prefer Linux))

Collapse
 
maxyudin profile image
Max Yudin

I have a robot to clean my parquet. Should I paste here all the information he got by sensors, or let him describe everything by himself?

Collapse
 
moopet profile image
Ben Sinclair

I'd love it if you pasted the sensor information and explained its relevance.

Collapse
 
billydev9821 profile image
Billy

Thanks for your article. It is really help to me.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.