DEV Community

Nikola Stojiljkovic
Nikola Stojiljkovic

Posted on

Using Scoop and Cmder to make PHP development on Windows bearable

Really short TL;WR (TooLong;Won'tRead) version:

  • Install .NET Framework 4.5 and PowerShell 5
  • Install Scoop by running the following in PowerShell:

    Set-ExecutionPolicy RemoteSigned -scope CurrentUser
    iwr -useb get.scoop.sh | iex
    
  • Install extras bucket (additional software repository):

    scoop bucket add extras
    
  • Install Cmder:

    scoop install cmder-full
    
  • Install base set of command-line tools useful for PHP/web development (run scoop search application_name for more available software) IMPORTANT NOTE: review which applications are installed with this command before running it, or it may clash with your manually installed versions:

    scoop install aws cacert git gzip zip unzip imagemagick memcached mkcert nano nvm openssl sudo wget ffmpeg
    
  • If you'd like to fully switch to Scoop, you can even install GUI applications:

    scoop install 7zip blender dbeaver discord gimp handbrake kdenlive okular nomacs notepadplusplus obs-studio paint.net postman screentogif vlc vscodium yed brave firefox thunderbird
    
  • Bonus: enjoy destroying what's left of Windows' pride with a move like:

    sudo nano /c/windows/system32/drivers/etc/hosts
    

Now to the article...

First of all - Windows is OK for PHP development... but it's only OK. Why? It's simple - most of the time you'll be deploying to Linux servers and your life would be much simpler if you could have the same set of tools in all environments (local and your servers). You also might have two computers, a dual boot system or simply prefer Linux command line tools and Bash to PowerShell.

There are a couple of options to use Linux tools on Windows and trust me, I've extensively tested all of them:

  • Cygwin or MSYS2. These are great, but huge and can be complicated to update and manage. These tools are built primarily to provide an environment for building native multiplatform applications in various programming languages, including building desktop software from source. If you are going to build desktop software from source, then by all means go for one of these. But if you primarily need Linux-like environment to work on web projects written in PHP/JavaScript then this might be an overkill.
  • MinGW/Win-Builds - simple and lightweight... and it's already been used by Cmder without you having to know about it.
  • WSL2 seems like a good option, until you try to use it every day and discover its downsides.

    First of all, for a long time you were not able to access WSL files in Windows Explorer (unless you hacked it). Microsoft did release an update to solve this, but it was too late for me - I've already set up everything I need in Scoop.

    The next thing which was bothering me with WSL is - do I really need a whole secondary operating system just to do web development? How to integrate WSL with PHPStorm? Will I need multiple environments for applications written in different versions of PHP and how can I manage that?

    The knowledge of using Windows to set up PHP development environment was already there, I just need a couple of tools from Linux to make my life easier - not a whole system which needs to be set up from scratch and separately updated and maintained (with all the potential issues coming with the updates).

  • Docker. Of course, I use Docker as well, but wouldn't it be nice to run terminal and debug tools on your main operating system? Also, Docker can eat up a lot of your time while you try to set up all of the development tools you need. For example, I have tried, on multiple occasions, to set up XDebug in a Docker container and bind it to host's PHPStorm, browsers and terminal (from various official and unofficial guides), but without any luck. If I manage to do that, I'll post a guide to help any other poor soul who spent hours trying to set it up without success.

Advantages of using Scoop with Cmder for web development

  • Linux terminal commands and Bash support. That's the main advantage. Being able to use ls, grep, curl, wget, sed and run Bash scripts directly on your host Windows system is simply priceless.
  • All installed applications (especially terminal applications) are automatically included in your PATH and can be run from Cmder without any configuration. You want gzip, nano, vim,...? Just install it with Scoop and you can use it in Cmder.
  • All of your project's files and tools are on your native Windows filesystem. You can view, edit and use them with any tool you already have installed on your Windows, without any additional configuration.
  • No virtual operating system also means no time wasted on maintenance. Update only applications installed with Scoop when you want.
  • No changes in PHP debugging setup. If you are used to work on Windows, your workflow will not change (if you explicitly don't want to).
  • Zero-configuration installation of software without running GUI installers.
  • You can automate setting up the environment on other machines with a simple non-interactive console script (PowerShell, Bash,... whatever you prefer).
  • Reinstalling Windows and setting everything back up just went from "I'd rather chew my own leg off than even think about reinstalling Windows" to "I'll just run ONE command to install almost everything I need."

What's Scoop

Scoop is a command-line package manager for Windows. It's just like:

Installing Scoop

Scoop's homepage describes how to install Scoop in just a few seconds - and for a change, they are not lying... you literally need a couple of seconds:

  • Prerequisites are .NET Framework 4.5 and PowerShell 5 (or later). These are official download links, in case you need them.
  • Open PowerShell and change the execution policy (you might not need this, but here it is just in case):

    Set-ExecutionPolicy RemoteSigned -scope CurrentUser
    
  • Install Scoop with:

    iwr -useb get.scoop.sh | iex
    

Scoop organizes software into buckets. By default you'll have main bucket installed and enabled, but I highly recommend installing the extras bucket as well.
main bucket contains many zero-configuration terminal applications which are well known in Linux world. extras bucket has many applications which can be Linux ports (like Okular, for example) but can also be native Windows applications (like Firefox or Brave browsers, Discord, VLC, MySQL Workbench, Postman, Blender, Gimp...).

So, let's install the extras bucket right away:

scoop bucket add extras
Enter fullscreen mode Exit fullscreen mode

You'll only need a couple of commands

Running scoop help will list about 24 commands which are really simple and self-explanatory. However, you'll only really need a couple of them:

To search for an application:

scoop search your_search_term
Enter fullscreen mode Exit fullscreen mode

To install an application (or multiple applications at once):

scoop install application_name another_application yet_another_application
Enter fullscreen mode Exit fullscreen mode

To update Scoop and pick up the list of available software updates:

scoop update
Enter fullscreen mode Exit fullscreen mode

To update an application (make sure to run scoop update first to fetch the list of updates and see which applications have new versions available):

scoop update application_name another_application yet_another_application
Enter fullscreen mode Exit fullscreen mode

To remove previous versions of an application:

scoop cleanup application_name another_application yet_another_application
Enter fullscreen mode Exit fullscreen mode

To uninstall an application:

scoop uninstall application_name another_application yet_another_application
Enter fullscreen mode Exit fullscreen mode

To list all installed applications:

scoop list
Enter fullscreen mode Exit fullscreen mode

Install Cmder

Cmder is a portable console emulator for Windows. You'll need it to run Bash.

You can install Cmder with:

scoop install cmder-full
Enter fullscreen mode Exit fullscreen mode

The most important thing to note for Cmder is how to access Windows filesystem files in Bash. Instead of default Windows paths like:

cd C:\Windows
Enter fullscreen mode Exit fullscreen mode

just use:

cd /c/windows
Enter fullscreen mode Exit fullscreen mode

Everything else handles just like on Linux, including accessing your Windows user's home directory:

cd ~
Enter fullscreen mode Exit fullscreen mode

Integrating Cmder with your IDE

You can use Cmder as a terminal emulator inside your preferred IDE. Here are the guides for:

The full list of integration instructions is available on Cmder's Wiki page at: https://github.com/cmderdev/cmder/wiki

My set of tools for PHP/web development

Apart from what comes default with Cmder (basic commands like ls, curl, sed, tar,...), I also use many tools installed with Scoop, including (but not limited to):

  • AWS CLI (scoop install aws)
  • cacert (scoop install cacert) - CA certificates extracted from the Mozilla CA certificate store, in PEM format
  • git (scoop install git)
  • gzip, zip, unzip (scoop install gzip zip unzip) - very useful if you need compression in your PHP application. tar is included in Cmder by default. Fully compatible with PHP's gzip and zip extensions.
  • imagemagick (scoop install imagemagick) - an image processing tool. Fully compatible with PHP's imagemagick extension.
  • memcached (scoop install memcached) - Yes. Memcached on Windows.
  • mkcert (scoop install mkcert - GitHub link) - extremely easy to use tool for generating safe and trusted local certificates for development purposes.
  • nano, vim (scoop install nano vim) - because no Linux terminal is complete without them.
  • nvm (scoop install nvm) - Node Version Manager for NodeJS development and tools.
  • openssl (scoop install openssl)
  • sudo (scoop install sudo) - Oh... this one is FUN. It's sudo ... on Windows... just imagine the possibilities.
  • wget (scoop install wget) - curl is available in Cmder by default, install wget with Scoop if you need it. Just a reminder, you can easily use it in your PHP code and it will run just like you're running it on a Linux server.
  • ffmpeg (scoop install ffmpeg) - if you're working with video files.

And these are only command line tools. There are many GUI applications as well:

  • 7zip
  • Blender
  • DBeaver - a good GUI for databases
  • Discord
  • Gimp
  • Handbrake - video processing tool
  • Kdenlive - KDE video editing tool
  • Okular - KDE PDF viewer
  • Nomacs - Image viewer
  • Notepad++
  • OBS Studio - screen video recording and streaming
  • Postman
  • ScreenToGif - screen recording to (very small) GIFs
  • VLC - video player
  • VSCodium - de-branded open-source version of VSCode (without reporting to Microsoft)
  • yEd - the best graph editor on any platform

Conclusion and final notes

By installing just two tools: a package manager and a terminal emulator, you'll get convenience of using Linux tools and running Bash scripts on Windows and have all your files and tools directly on Windows file system - all of it while not having additional virtualization layers to manage and update.

There is also a php Scoop bucket for installing different versions of PHP. However, that's new even for me and I'll need to play with it for a while to see if it's any good.

A final note: I am not affiliated with Scoop or Cmder. They are simply free and open source tools which became irreplaceable in my daily work and, for me, they speed up development significantly - especially when I need Linux-native software compatible with PHP extensions (gzip, imagemagick, memcached,...).

Latest comments (0)