{"id":23,"date":"2024-08-01T20:00:00","date_gmt":"2024-08-01T19:00:00","guid":{"rendered":"https:\/\/josepineiro.com\/?p=23"},"modified":"2024-07-03T20:32:38","modified_gmt":"2024-07-03T19:32:38","slug":"setting-up-a-local-php-development-environment","status":"publish","type":"post","link":"https:\/\/josepineiro.com\/index.php\/2024\/08\/01\/setting-up-a-local-php-development-environment\/","title":{"rendered":"Setting up a local PHP development environment"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><strong>PHP skills update<\/strong><\/h3>\n\n\n\n<p>In the early 2000&#8217;s, when I was most actively doing web development on a freelance basis, I was using PHP for the backend without the help of any web frameworks.  I seamlessly ported all my code from my local environment to my shared webhost.  It wasn&#8217;t until I moved to working in Python that I truly concerned myself with the command line to isolate my different projects and manage each of their dependencies.<\/p>\n\n\n\n<p>Coincidentally, I stopped using PHP regularly sometime between 2005 and 2010. I had already begun to familiarize myself with its object-oriented features, despite improved OOP support just being released in newer versions. It was also a time when many of the popular web frameworks were being released. <a href=\"https:\/\/josepineiro.com\/index.php\/2024\/07\/03\/the-return-to-php-web-development\/\" data-type=\"link\" data-id=\"https:\/\/josepineiro.com\/index.php\/2024\/07\/03\/the-return-to-php-web-development\/\">See my post [The return to PHP web development]<\/a> . PHP&#8217;s <strong>Composer<\/strong>, the dependency manager, would not be released until 2012.<\/p>\n\n\n\n<p>Fast-forward a few years and I found that it was time to update my skillset in PHP.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><strong>What platform to use (on Windows)?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Github Codespaces<\/li>\n\n\n\n<li>Xampp<\/li>\n\n\n\n<li>Laragon<\/li>\n\n\n\n<li>VirtualBox<\/li>\n\n\n\n<li>Docker<\/li>\n<\/ul>\n\n\n\n<p>I liked the idea of going with <strong>Github<\/strong> <strong>Codespaces<\/strong> in order to have a fully remote dev environment that I can tap at any time.&nbsp; However, at the time of this writing, Codespaces does not appear to have any PHP templates.&nbsp; And while it may be simple enough to install from the terminal and get everything running, the lack of online documentation suggests that there may be some considerable complications along the way.  The lack of information -or my failure to locate it- could also be due to the trendy dislike for PHP, even though it runs a good part of the web.<\/p>\n\n\n\n<p>On second thought, once I dive in, it should not be overly complicated to set up a PHP environment in Codespaces. However, creating separate repos and environments just for my goal of reviewing different frameworks seems cumbersome.<\/p>\n\n\n\n<p>The other option is to develop on my local machine.  Since I&#8217;m on Windows, a popular option is to use <strong>Xampp<\/strong>.  I&#8217;ve used Xampp (and <strong>Wamp<\/strong>) for years and while it is fairly easy to use, it seems to have taken a toll on my computer, in terms of resources, at the time.  Although the project is actively maintained and widely used, I had a hard time believing that a newer product hadn&#8217;t come out in all this time, for example one that could favor the use of the command line, which is a must for other languages like Python.  I would later discover an option that intrigued my interest called <strong>Laragon<\/strong>.<\/p>\n\n\n\n<p><strong>VirtualBox<\/strong> and <strong>Docker<\/strong> are two other very interesting options.  I had to dive a little deeper to learn the differences of these beyond my general knowledge.  VirtualBox is good for spinning up different operating systems in a virtual environment.  Each virtual machine on the host machine has its own operating system that may be different from the host operating system.  However, <strong>Docker containers are lightweight because they share the host machine&#8217;s operating system and only runs the necessary components in isolation.  Docker containers have the advantage that they are portable and can be quickly spun up and down, however, configuration for each project can take some time.<\/strong> While Docker might have a steeper learning curve than other options, these benefits, along with popularity, make it valuable to learn and use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-accent-color has-text-color\">And the winner is: Laragon<\/h2>\n\n\n\n<p>After reviewing the options, I decided to go with <strong>Laragon<\/strong>.\u00a0 I needed a lightweight option that wouldn&#8217;t weigh down on my aging laptop.\u00a0 I wanted something quick to spin up and configure so that, if I wanted to, I can quickly learn and test out the different PHP frameworks or CMS platforms like <strong>Drupal<\/strong> and <strong>Joomla<\/strong>, the latter which I toyed with long ago.<\/p>\n\n\n\n<p>Another reason I chose Laragon is because I recently canceled the web hosting account I was using for personal and client projects.\u00a0 Instead of migrating projects to a new web hosting company, the idea of starting with a clean slate is quite appealing. If I ever want to recover an old project, I can do so locally with Laragon.<\/p>\n\n\n\n<p>Laragon installs for you all the tools you need and makes others easy to add.  It even comes with PHP&#8217;s Composer.  Laragon even provides a quick share feature using <strong>Ngrok<\/strong> in case you need to share your project with the outside world.  (I&#8217;ve had to use Ngrok for a separate side project built on Flask in order to test and integrate with a third party product).<\/p>\n\n\n\n<p>It must be said that the official Laragon website does a very good job of selling itself via testimonials, &#8211; particularly of users abandoning Xampp -, and linked articles.  The product is portable.  As per the site: <em>&#8220;Laragon has an isolated environment and use built-in service orchestration, so it doesn\u2019t affect your OS.<\/em>&#8220;<\/p>\n\n\n\n<p>One <strong><em>Reddit<\/em><\/strong> user considered moving from Laragon to Docker, but described building a <strong>dockerfile<\/strong> for each project &#8220;<em>a pain in the ass<\/em>.&#8221; So, while I am certainly interested in learning and becoming proficient with Docker, Laragon currently fulfills my needs as I venture back into PHP web development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>PHP skills update In the early 2000&#8217;s, when I was most actively doing web development on a freelance basis, I was using PHP for the backend without the help of any web frameworks. I seamlessly ported all my code from my local environment to my shared webhost. It wasn&#8217;t until I moved to working in &#8230; <a title=\"Setting up a local PHP development environment\" class=\"read-more\" href=\"https:\/\/josepineiro.com\/index.php\/2024\/08\/01\/setting-up-a-local-php-development-environment\/\" aria-label=\"Read more about Setting up a local PHP development environment\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,2],"tags":[9,6,10],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-blog","category-web-development","tag-laragon","tag-php","tag-xampp"],"_links":{"self":[{"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":8,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":46,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions\/46"}],"wp:attachment":[{"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/josepineiro.com\/index.php\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}