All right guys, hey welcome back. Okay in this one were going to take a look at setting up PHP. Im going to open up a browser in Terminal or you could use finder to open your browser or whatever it doesnt matter. You can do this in multiple ways. Ive opened up safari here using terminal and then Im going to type in php.net in the browser. Im going to go here and this is the official PHP site as of this release we are sitting at version PHP 8.1. Which is a major upgrade for PHP. Before we get started let me just give you a brief overview of what PHP is. PHP is a server-side language, its a general-purpose scripting language and its especially really good for the web. So like they say here on the site it powers everything from your blog to your most popular websites in the world. So PHP is highly saturated across the web and its used a lot in a lot of web pages. Originally it was made by Rasmus Lerdorf in 1994. A Danish Canadian who went to Waterloo University. So just around the corner from here in our region which is nice to know. Now its being maintained by the PHP group I believe lets just cheat here a little bit and lets check out the credits. So here we are, this is the group thats maintaining this and you know there are a lot of people and its like a really great community. Some pros and cons of PHP is that its a really simple scripting language to learn. PHP language is fast, so websites typically run very fast depending on what youre doing. Its stable because its been around for such a long time. Its also open-source which means its FREE you dont have to pay for a license to use PHP or develop software products. And the community support like I said once again is actually just really good. If you wanted to download PHP and install it manually, you can go about doing it like this. Depending on your platform. Its also cross-platform. So you know that PHP works on Mac, Windows and Linux. But were not really gonna take this approach were going to take a look at --- lets go back to the main page for a second. Were going to type in the manual. So, I just accessing the PHP manual here. This brings up the PHP manual getting started section. So this tells you know, what PHP is. A simple tutorial on how to use it. How to set it up and then heres the installation configuration. For our purposes, were going to install it on a mac. So I think prior to macOS 10, PHP used to come pre-installed on that platform and then macOS Monterey kind of just removed that which is in my opinion kind of good in a way because like, I wouldnt really trust a default thing installed by the operating system just out of the box. Because you may want to make some modifications and change these things so, its kind of a good move I feel like. Lets just jump to the macOS installation. Now there are many ways that you can install this, some people use a package solution like MAMP, WAMP, XAMP were going to take a different approach on this channel, and were going to look at things just a little bit differently. So for this if you kind of check out the packages. You will see that there are packages that you can use to install PHP. Please check out the Homebrew video. I provided a video on how to install and set up Homebrew. That will help you use that package manager to help you install various packages and PHP is one of them. So were going to take that approach were going to use the Homebrew approach and the command here is just "brew install php". Well just quickly jump out to the documentation on Homebrew to kind of have a look here. This is installing homebrew instructions. And once you do that were going to search for PHP and these are the instructions that were going to follow verbatim. Just to install PHP, and in this part, its also known as PHP 8.1. so as you can see depending on whatever bottle or package youre using its supported across all these platforms. If youre using an Intel mac with these operating systems, you can see that it is here and also Apple Silicon. You get the same thing and the stable version as of this right is PHP 8.1.1. So lets just do that one. Well jump back into mac Terminal and well just paste in that command that we copied from php.net. And well just run that. So hit enter, and at this point um this may take a while depending on your operating system, the speed of your internet, or the computer you using. So you could just hang around and watch. Or you can just go grab a drink or do something else because this might be a minute. All right so, once your installation is complete youll see that there are a few more things that you can do it towards the bottom here. One would be if you wanted to check out the php.ini file which is just like the configurations for PHP and stuff like that. Were just going to type in "code" and were going to just copy this here. And were going to just paste it below here. Hit enter. Its going to open an instance of Visual Studio Code. After running the command this is what youll see and this is where you can you know call different configurations and aspects of PHP behaviour using this file. So well just close that up. What I like about Homebrew is that you can install multiple versions of PHP so I could be like "brew install" and I could just be PHP and Im going to take the version lets say 7.4. So then itll do the same thing Ill fast forward the video, so you can see but itll install you know PHP 7.4 and PHP 8.1 which we already have installed. So once thats all done you can validate that you have PHP installation running. By typing "php -v" that will tell you the version. Currently, Im running PHP 8.1.1 Which is the latest version and its a major release and a major upgrade for PHP. And it has a bunch of new features and its very quick. At the end of the day, you can switch between versions of PHP if you needed to do so. Like say youre running something and you need a version - I dont know PHP 7.4 or like PHP 8 or whatever. You can do that by just adding this Im going to say "@7.4".
Actually, I made a mistake here PHP 8.1. So we have to unlink it first so thats why we got the error. Actually, thats a good thing that this popped up so you guys can see that. Then we will "brew link php" and well link version @7.4. Again well try that. So you need to like have the software installed into your "PATH" and in our case, our path is going to be the .zshrc file that weve talked about previously and you can do that. If you want to validate this you can say "php-v" and you can see that youre currently running PHP 7.427. All right and thats how you install PHP onto a mac using Homebrew and you can do multiple versions as I said once again, but were taking this approach versus the other approaches because at a later point well be taking a look at different frameworks and things like that. The way this installation is going to be set up will be pretty helpful for you guys to follow along. If you guys have any questions or you like the video dont forget to subscribe leave any comments that you have below and if youre doing work with PHP just note that should have this PHP manual or this site kind of in your pocket. Because its a great online reference and has amazing community support if you get stuck with certain things its actually really useful to refer to the site and find any help. All right guys, thats it for this one and Ill see you in the next one take care.