{"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

PHP<\/h2>\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 .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

Now if I want to switch to a different PHP version, I just type phpswitch 8.2<\/code> into my terminal and I’m up and running with 8.2.x.<\/p>\n\n\n\n

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

NodeJS<\/h2>\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

$ 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

Easy as that… and pie 🥧 😋.<\/p>\n\n\n\n

<\/p>\n\n\n\n


\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":"\nLocal PHP and NodeJS Version Control | Nate Finch<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Local PHP and NodeJS Version Control | Nate Finch\" \/>\n<meta property=\"og:description\" content=\"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 […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\" \/>\n<meta property=\"og:site_name\" content=\"Nate Finch\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-28T14:55:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-28T14:55:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/n8finch-site.site.strattic.io\/wp-content\/uploads\/2022\/05\/local-dev.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1282\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nate\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@n8finch\" \/>\n<meta name=\"twitter:site\" content=\"@n8finch\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nate\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\"},\"author\":{\"name\":\"Nate\",\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"headline\":\"Local PHP and NodeJS Version Control\",\"datePublished\":\"2022-05-28T14:55:41+00:00\",\"dateModified\":\"2022-05-28T14:55:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\"},\"wordCount\":303,\"publisher\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\",\"url\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\",\"name\":\"Local PHP and NodeJS Version Control | Nate Finch\",\"isPartOf\":{\"@id\":\"https:\/\/n8finch.local\/#website\"},\"datePublished\":\"2022-05-28T14:55:41+00:00\",\"dateModified\":\"2022-05-28T14:55:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/n8finch.local\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Local PHP and NodeJS Version Control\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/n8finch.local\/#website\",\"url\":\"https:\/\/n8finch.local\/\",\"name\":\"Nate Finch\",\"description\":\"All the things, keeping it clever...🤓\",\"publisher\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/n8finch.local\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce\",\"name\":\"Nate\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg\",\"contentUrl\":\"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg\",\"width\":796,\"height\":792,\"caption\":\"Nate\"},\"logo\":{\"@id\":\"https:\/\/n8finch.local\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Local PHP and NodeJS Version Control | Nate Finch","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/","og_locale":"en_US","og_type":"article","og_title":"Local PHP and NodeJS Version Control | Nate Finch","og_description":"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 […]","og_url":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/","og_site_name":"Nate Finch","article_published_time":"2022-05-28T14:55:41+00:00","article_modified_time":"2022-05-28T14:55:42+00:00","og_image":[{"width":1920,"height":1282,"url":"https:\/\/n8finch-site.site.strattic.io\/wp-content\/uploads\/2022\/05\/local-dev.jpg","type":"image\/jpeg"}],"author":"Nate","twitter_card":"summary_large_image","twitter_creator":"@n8finch","twitter_site":"@n8finch","twitter_misc":{"Written by":"Nate","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#article","isPartOf":{"@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/"},"author":{"name":"Nate","@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"headline":"Local PHP and NodeJS Version Control","datePublished":"2022-05-28T14:55:41+00:00","dateModified":"2022-05-28T14:55:42+00:00","mainEntityOfPage":{"@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/"},"wordCount":303,"publisher":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/","url":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/","name":"Local PHP and NodeJS Version Control | Nate Finch","isPartOf":{"@id":"https:\/\/n8finch.local\/#website"},"datePublished":"2022-05-28T14:55:41+00:00","dateModified":"2022-05-28T14:55:42+00:00","breadcrumb":{"@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/n8finch-site.site.strattic.io\/local-php-and-nodejs-version-control\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/n8finch.local\/"},{"@type":"ListItem","position":2,"name":"Local PHP and NodeJS Version Control"}]},{"@type":"WebSite","@id":"https:\/\/n8finch.local\/#website","url":"https:\/\/n8finch.local\/","name":"Nate Finch","description":"All the things, keeping it clever...🤓","publisher":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/n8finch.local\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/n8finch.local\/#\/schema\/person\/619068414583ca3c43bb135af49a47ce","name":"Nate","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/n8finch.local\/#\/schema\/person\/image\/","url":"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg","contentUrl":"https:\/\/n8finch2024.local\/wp-content\/uploads\/2020\/11\/nate-pic_ykd6mq.jpg","width":796,"height":792,"caption":"Nate"},"logo":{"@id":"https:\/\/n8finch.local\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/2742"}],"collection":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/comments?post=2742"}],"version-history":[{"count":5,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/2742\/revisions"}],"predecessor-version":[{"id":2749,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/posts\/2742\/revisions\/2749"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/media\/2744"}],"wp:attachment":[{"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/media?parent=2742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/categories?post=2742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/n8finch2024.local\/wp-json\/wp\/v2\/tags?post=2742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}