Even the longest journey starts with the first steps…– Some wise guy
Hej you ?, you want to start your developer career with php and you have no clue how to start and you do not want to pay hundreds or more dollars to start?
No problem, welcome to this post.
First: You do not have to pay anything to get started and make your first steps. All you need is a computer with windows (for this tutorial) and an internet connection (you can read this, you sure have one ?). And some time …. time is your currency to get into this developer thing.
To install php, you need to download it from the windows download section of the php homepage. Go to https://windows.php.net/download/ and choose your desired version. I recommend using the latest x64 „threat safe“ version – in most cases, this is the second option to download. You will propably learn about „thread safe“ and „non-thread safe“ in the future, but for starting, choose the „thread safe“ one ?.
Download the ZIP file!
Once downloaded, unzip it to a destination you like. I do have my php in „d:\php“ but the coise is up to you. Once you unzipped it, remember the file path to your php.
Now, you have downloaded php and unzipped it, but you will not be able to work with it properly. We have to setup the „path“ variable to your installation.
⚠ I assume you to be on at least Windows 10 for the next steps, for older versions locations may differ.
Open your system settings by pressing `Win` (the windows logo key) and `i` the same time. In the search field, type `path` and chose `edit system variables`. Chose the middlest tab called „Advanced“ and on the bottom there, click on „System variables„.
You see a new dialog, in the lower one search for „PATH“ and double-click that. Say „New“ and insert the path to your php installation. After that click on „Ok“ and close all dialogs with „Ok“. A reboot might be required (never had that, maybe you need to do it, just saying).
You can test it simply by opening your console (right click onto the windows-logo and chose „PowerShell“) and type `php -v`. You should get a result like this:
If you get an error, check the path you entered in your `path` variable; maybe you are the one who needs the reboot!
So, php is installed and ready to run ?.
The next thing you will need is a local database. For this MariaDB is a very good choise. It’s a fork of MySQL and full compatible with it … and on top: it’s free for you as learner ?.
Go to https://mariadb.org/download and choose your favorite. I recomend using the default (latest version, x64, Windows, MSI Package) for this is the easiest to start with.
After downloading, installed it as normal. The installer will ask you to setup a passwort for the `root` user … for this is a local installtion you can also leave it empty; in all cases, you will need this password in your code often, so choose one you do remember!
Ok, MariaDB is also installed now ?
If you courious how to start it: In the installtion you hopefully set it up as service, so just hit your windows-key, type „service“ and start the „services“ app, there you will find a service called „MariaDB“ and you can start/stop/reload it from there.
Connecting to MariaDB from php
When ever you want to connect from your php to your MariaDB and you let the setup use all as default, your database is reachable with
||whatever you setup
Simple as that.
Now, you are ready to develop great things with php and a database. Let’s finish this post with another quote:
Build something great!– Some other wise guy