<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Maxime Veber</title>
    <description>The latest articles on Forem by Maxime Veber (@nek_dev).</description>
    <link>https://forem.com/nek_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F67383%2F9dd2a5ca-4aac-4657-8c0b-1a7eec9548a9.png</url>
      <title>Forem: Maxime Veber</title>
      <link>https://forem.com/nek_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nek_dev"/>
    <language>en</language>
    <item>
      <title>How to setup dev PHP/MariaDB (MySQL) environment on Windows</title>
      <dc:creator>Maxime Veber</dc:creator>
      <pubDate>Thu, 06 May 2021 09:48:52 +0000</pubDate>
      <link>https://forem.com/nek_dev/how-to-setup-dev-php-mariadb-mysql-environment-on-windows-jdn</link>
      <guid>https://forem.com/nek_dev/how-to-setup-dev-php-mariadb-mysql-environment-on-windows-jdn</guid>
      <description>&lt;p&gt;TL;DR: you don't need WAMP, or Apache or Nginx in your development environment. And it's not even about docker, just standard installation with protips. 😎&lt;/p&gt;

&lt;h1&gt;
  
  
  Chocolatey to the rescue
&lt;/h1&gt;

&lt;p&gt;Yes. Because the first thing that significantly changes between Windows and Linux or macOS is the package manager, they have apt, yum, yaourt, homebrew... Windows has nothing by default (but not for long, &lt;a href="https://devblogs.microsoft.com/commandline/windows-package-manager-preview/"&gt;the future looks bright&lt;/a&gt;!).&lt;/p&gt;

&lt;p&gt;But here comes Chocolatey. Yes, it's a package manager. Not official, it does not contain all the software you want. But well, it provides already a lot!&lt;/p&gt;

&lt;p&gt;For instance, you can install &lt;a href="https://community.chocolatey.org/packages/php"&gt;PHP&lt;/a&gt;, but also &lt;a href="https://community.chocolatey.org/packages/phpmyadmin"&gt;phpMyAdmin&lt;/a&gt; and &lt;a href="https://community.chocolatey.org/packages/mariadb"&gt;MariaDB&lt;/a&gt; (which replace MySQL).&lt;/p&gt;

&lt;p&gt;To install Chocolatey, just follow the &lt;a href="https://chocolatey.org/install"&gt;getting started&lt;/a&gt;, or run this command in a terminal (launched in mode administrator).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Installing PHP
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Actual installation
&lt;/h2&gt;

&lt;p&gt;Now you have Chocolatey, we can install PHP. Run this in a terminal in administrator mode (right click on terminal / open as administrator):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You probably need to restart your terminal now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using PHP directly
&lt;/h2&gt;

&lt;p&gt;You may ask why not installing a webserver like Apache or Nginx as well, the short answer is: &lt;em&gt;you don't need one&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To run your project, use in the terminal the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -S localhost:1337
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;php -S&lt;/code&gt; will start the PHP server (for development only)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;localhost:1337&lt;/code&gt; represents the host and the port to listen on, if you want to expose the server you will probably need to use &lt;code&gt;0.0.0.0:1337&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The server points to the current directory by default, use the option &lt;code&gt;-t&lt;/code&gt; to specify a folder&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You access your website on &lt;a href="http://localhost:1337"&gt;http://localhost:1337&lt;/a&gt;! ✨&lt;/p&gt;

&lt;p&gt;If you're using a router (a single entry point like many frameworks nowadays), you can also specify one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -S localhost:1337 index.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bonus track: install composer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://getcomposer.org/"&gt;Composer&lt;/a&gt; is the package manager of PHP. And guess what, it's also available &lt;a href="https://community.chocolatey.org/packages/composer"&gt;in choco&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;In a terminal as administrator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install composer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Installing MariaDB
&lt;/h1&gt;

&lt;p&gt;Just like PHP. It is super-super-easy, open a terminal in administrator (or use &lt;a href="https://community.chocolatey.org/packages/wsudo"&gt;wsudo&lt;/a&gt; 😎) and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install mariadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You're all set. MariaDB is now available on your computer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing phpMyAdmin
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;MariaDB will work with PHP as a replacement for MySQL perfectly. You can also use any MySQL client for that. For example, you can use PHPStorm internal client or MySQL Workbench!&lt;/p&gt;

&lt;p&gt;But most of us are used to a very specific client (which is incredibly simple to use): phpMyAdmin.&lt;/p&gt;

&lt;p&gt;Let's install it, it's just like the 2 previous tools!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install phpmyadmin
# Do not forget to run it as administrator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;phpMyAdmin requires some PHP extensions to be enabled before it works. This is documented in the &lt;a href="https://github.com/Nek-/choco-phpmyadmin#php-configuration"&gt;readme of the package&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Go in the install directory of PHP (for me it's &lt;code&gt;C:\Tools\php...&lt;/code&gt;), you can find it with the command &lt;code&gt;php --ini&lt;/code&gt;. And copy/paste &lt;code&gt;php.ini.development&lt;/code&gt; to &lt;code&gt;php.ini&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now edit this file and add (or uncomment) the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;extension=mysqli
extension=openssl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running phpMyAdmin
&lt;/h2&gt;

&lt;p&gt;You're all set. Just run the phpMyAdmin command (it runs a php server for you!), in your terminal type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;phpmyadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's all folks! You have setup a complete workspace to build an application in PHP that uses MariaDB with phpMyAdmin client for MySQL! ✨ &lt;/p&gt;

&lt;p&gt;You can now access phpmyadmin in your browser on &lt;a href="http://localhost:3333"&gt;http://localhost:3333&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Ok, and why not WAMP?
&lt;/h1&gt;

&lt;p&gt;WAMP is old. Outdated. For example, you can't even get the very last version of PHP with WAMP.&lt;/p&gt;

&lt;p&gt;But it also adds a webserver (apache), the default configuration is not bad to learn PHP, but when it comes to run modern applications... Well, it becomes a pain to configure properly.&lt;/p&gt;

&lt;p&gt;The method I explain here is easy but also has a serious advantage: you understand what you're doing (when WAMP is a complete package with a complex overhead).&lt;/p&gt;

&lt;p&gt;Hope you like it. 👋&lt;/p&gt;

</description>
      <category>php</category>
      <category>windows</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
