PHP Basics

Installation & Setup

Maximiliano Firtman

Maximiliano Firtman

Independent Consultant
PHP Basics

Check out a free preview of the full PHP Basics course

The "Installation & Setup" Lesson is part of the full, PHP Basics course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano discusses the local and production requirements for PHP. Locally, a PHP interpreter is required. The interpreter can be installed individually or as part of a full LAMP stack, which includes Linux, Apache, MySQL, and PHP. In production environments, most shared hosting services support PHP or can be run in a cloud provider through a Docker image.

Preview
Close

Transcript from the "Installation & Setup" Lesson

[00:00:00]
>> Maximiliano Firtman: Okay, so tools that you need or we are going to use. VS Code with extension, VS Code by default does not support PHP, so the first time you try to open a .php file, it will tell you hey, you need some extension. So I will show you a lot of extensions and there are a lot of extensions, some good ones and bad ones.

[00:00:19]
Now there is a pattern in the VS Marketplace, where there are a lot of extensions that are really cool, or they were really cool, but now they have a pro version, where it helps you play with AI or whatever. And the problem is that they're getting really annoyed because the free part, it's all the time saying, no, this is pro.

[00:00:39]
So you're typing code, you see an underline, you say, okay, what's going on here? You hover, the underline says, you have to pay for seeing the warning. I say, come on, don't show me the warning or don't bother me with that, but anyway, PhpStorm was a classic IDE for PHP, it's still there, it has a huge fan base.

[00:01:00]
It's kind of an IDE only for PHP developers, okay? If you're coming from other platforms these days, you won't like PhpStorm or anything different from VS Code, probably, because you are used to one way of doing things. And, of course, PhpStorm is coming from a previous RL of IDE, so it has its own unique ideas.

[00:01:24]
NetBeans is being used a lot mostly in the enterprise to do PHP, as well as with Eclipse. There is Eclipse PDT, PHP development tools, where you can write with Eclipse. Yeah, again, if you're a web developer If you're a JavaScript developer or a mobile app developer, you probably will stay with your IDE.

[00:01:47]
You don't wanna go into those IDEs, and even there is a sense studio, I remember this one was huge at the time, 2005, things like that. This is not free, so it's an IDE you have to pay, and mostly, it's for companies. So, if you will work for a company, I know that it's using CodeIgniter or things like that, there is a good chance that they will pay the license for Zend Studio.

[00:02:11]
So then they're using Zend Studio, that is an IDE specifically targeting PHP developers. Okay, so, another definition before actually writing code that probably you have heard that it's typically around PHP is the LAMP stack. So, it's a backend stack that became popular with PHP, that means, we're going to use Linux, Apache, MySQL, and PHP.

[00:02:40]
In production, maybe that doesn't mean that your computer needs to be Linux, okay, but in production, the server will be Linux, then Apache will be my web server. MySQL or now MariaDB, that is the open source version of MySQL, that is an Oracle-based database these days. They still keep the M as the first letter, so we can still say MySQL and LAMP will work.

[00:03:03]
Today, we are not going to work with LAMP, we will just play with PHP, okay? But have in mind that that was a pretty common stack of tools that we were all the time using together, okay? That doesn't mean that today, today, you can use the cloud. So then you can use cloud-based providers to run your PHP scripts.

[00:03:28]
So then you can use any database, you can use MongoDB if you want, wherever, you don't need to follow that stack, that was common in the early 2000s, okay? Now, you can just use PHP as your scripting language and then use wherever else you want for the rest of the layers.

[00:03:46]
Okay, so installing PHP, setting up PHP. So, you need to install PHP in your computer and your server in case you wanna use PHP for your server. So most of them, if you are going to hire a server for PHP, it will be there, of course, you can use a classic hosting company, or you can use the cloud.

[00:04:12]
So Amazon, AWS, Azure, even some smaller companies like Vercel that they have Next.js and Cool stuff, they also support PHP. So maybe they don't support PHP in the same way as in the 2000s, but Percel, for example, to keep you php.percel. So if you follow the step, for example, you can even host PHP for free at Vercel.

[00:04:38]
Vercel, you can start with a free tire. And they support PHP remote functions. The thing is that the way to develop your app is different because the whole Vercel infrastructure is different than a normal hosting. But you can still, so if you're doing Next.js, maybe you know Percel because they are the team behind Next.js and you can, of course, publish Next.js apps or Nuxt.js apps as well.

[00:05:05]
But also you can write PHP. Okay, so PHP is now integrated with the modern pipeline also. It's not just all FTP-based web hostings, where you need to upload your files manually. You can still integrate this with GitHub and all the rest of the modern ecosystem, okay, makes sense?

[00:05:28]
So, then, it's available for different operating systems and installation methods. So, remember I mentioned when we started, you can go to php.net and download if you want, but actually, that download link is more suitable for production, not for development purposes. So that manual download, I mean, you can do that, if you are comfortable with working, you can even download the source code and build PHP yourself, okay?

[00:05:55]
It's possible, but as developers, mostly if you're a web developer, you probably want a package manager, on the Mac, you have brew, on Linux, you have several options available there, so, well, you can quickly install it and set it up without hassle. So if you're on a Mac, you just open a terminal, for example, and you say, brew, install PHP, that's all.

[00:06:22]
And then you wait, okay? It will download everything, and after that, so after you do that, you can run PHP and see if something happens, and you say, nothing happens. But actually, there is something. So it's actually the premise, this is also a common line, but I didn't get any error, so that's good, but if you say, php -v, I get a version.

[00:06:44]
So that means that my PHP installation worked. For Windows, if you're on Windows, you can also do something like that, but it takes more steps, to be honest. It's better to install, I think it's even the version that is recommended here in the documentation. As far as I remember, so if you go to English Manual, Installation on Windows, well, Install Requirements, Recommended Configuration, so you have all the step-by-step, here, yeah, I was remembering correctly.

[00:07:16]
The first one that is recommended is XAMPP. Actually, I used XAMPP for maybe a decade. I'm talking from 2008 to 2018 and things like that. So when I was setting up my new computer, my first step after the operating system was to install XAMPP. It was part of my process all the time.

[00:07:38]
So it was, I need XAMPP. What's XAMPP? XAMPP is a tool to install the whole stack. So Apache, now MariaDB, before it was MySQL, now it's MariaDB, PHP, and Perl. So, on Windows, it's also available for Mac and Linux if you want, you can also use XAMPP. As a quick and simple way to get PHP up and running.

[00:08:05]
You will also get other things up and running that I'm not sure if you want. We are not going to use the other things this day, we're not want to use Apache, we are not going to use MarieiDB or Perl or whatever, but anyway, you will get PHP as one, okay?

[00:08:19]
So, my recommendation is to Windows, try XAMPP. If you are on Mac or Linux, it's better to just download PHP with one of the package manager, brew, or the other one you see on the page. Or if you want, you can also download XAMPP. One of the problems on the Mac, at least, is that the XAMPP file that you download, it has an installer, but the installer is not signed using an Apple certificate.

[00:08:47]
So if you have a modern MacOS, it will say, no, no, I'm not going to install this because I cannot verify the developer identity, so then you need to go to security. If you are a Mac user, you know this, but you need to go to security and enable that and you will be careful.

[00:09:05]
You can have some insecure code and okay. And also, if you like it, you can install PHP through Docker. You have also the instructions on the PHP website. So, it's modernized in that way, so you can also install it through Docker or, well, use a LAMP stack installer.

[00:09:26]
So, typically, we need a server, and servers that were the most common ones are Apache, Nginx, Lightspeed, IIS. And today, actually, every cloud-based, not every, but most cloud-based provider will offer you a way to execute PHP scripts from an HTTP request. Okay, but have in mind that PHP is not responsible for creating the server, it's responsible for receiving the request.

[00:09:58]
Doing something and makes the response, but it's not the server itself.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now