{"id":2742,"date":"2022-05-28T23:55:41","date_gmt":"2022-05-28T14:55:41","guid":{"rendered":"https:\/\/dev-n8finch.pantheonsite.io\/?p=2742"},"modified":"2022-05-28T23:55:42","modified_gmt":"2022-05-28T14:55:42","slug":"local-php-and-nodejs-version-control","status":"publish","type":"post","link":"https:\/\/n8finch2024.local\/local-php-and-nodejs-version-control\/","title":{"rendered":"Local PHP and NodeJS Version Control"},"content":{"rendered":"\n
When working on projects with your local computer, it\u2019s essential to be able to test new versions of the languages you\u2019re using. Browser JavaScript is fairly straightforward: use the browser, make sure it\u2019s updated, etc.<\/p>\n\n\n\n
However, with server-side languages (like PHP, NodeJS, Python, Go, etc.), there\u2019s a little more nuance. Some systems come with languages installed on them (I tend to work on a Mac), but they usually come with a single version, and there isn\u2019t a UI or straightforward way to update them.<\/p>\n\n\n\n
We tend to have vertualized environments for this kind of thing, but if you\u2019re looking to install and easily switch between local versions versions of a language you\u2019re running, these two repositories might be helpful.<\/p>\n\n\n\n
Note: I\u2019m on a Mac, so these are what I use.<\/p>\n\n\n\n
<\/p>\n\n\n\n
I’ve been using Homebrew PHP<\/a> for a bit now and really like how easy it is to get, use, and upgrade different PHP versions.<\/p>\n\n\n\n There are installation instructions in the Github repo, as well as commands for downloading, upgrading, and changing PHP versions. Since those commands are hard to remember, I’ve created a few bash functions and put them in my Now if I want to switch to a different PHP version, I just type This has made testing new PHP features and staying up to date with package requirements easy.<\/p>\n\n\n\n <\/p>\n\n\n\n Similarly, using Node Version Manager<\/a> has been a breeze for switching between versions of NodeJS.<\/p>\n\n\n\n Installation instructions and commands are available in the repo.<\/p>\n\n\n\n Here are some examples of commands you can use (from the repo):<\/p>\n\n\n\n Easy as that… and pie 🥧 😋.<\/p>\n\n\n\n <\/p>\n\n\n\n Photo by Ilya Pavlov<\/a> on Unsplash<\/a><\/p>\n","protected":false},"excerpt":{"rendered":" When working on projects with your local computer, it\u2019s essential to be able to test new versions of the languages you\u2019re using. Browser JavaScript is fairly straightforward: use the browser, make sure it\u2019s updated, etc. However, with server-side languages (like PHP, NodeJS, Python, Go, etc.), there\u2019s a little more nuance. Some systems come with languages […]<\/p>\n","protected":false},"author":1,"featured_media":2744,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[1],"tags":[],"yoast_head":"\n.bash_aliases<\/code> file:<\/p>\n\n\n\n
# PHP version management for Homebrew PHP\n# https:\/\/github.com\/shivammathur\/homebrew-php\nphpget () { brew install shivammathur\/php\/php@"$1" }\nphpswitch () { brew link --overwrite --force shivammathur\/php\/php@"$1" }\nphpupgrade () { brew upgrade shivammathur\/php\/php@"$1" }<\/code><\/pre>\n\n\n\n
phpswitch 8.2<\/code> into my terminal and I’m up and running with 8.2.x.<\/p>\n\n\n\n
NodeJS<\/h2>\n\n\n\n
$ nvm use 16\nNow using node v16.9.1 (npm v7.21.1)\n\n$ node -v\nv16.9.1\n\n$ nvm install 12\nNow using node v12.22.6 (npm v6.14.5)\n\n$ nvm ls\n v10.23.0\n v12.20.0\n v14.18.1\n-> v16.15.0\n system\ndefault -> 12.20.0 (-> v12.20.0)\nnode -> stable (-> v16.15.0) (default)\nstable -> 16.15 (-> v16.15.0) (default)\n\n$ nvm ls-remote\n(will output all the versions available to install... too many to list here 🤓)<\/code><\/pre>\n\n\n\n
\n\n\n\n