Installing PHP, Composer & Laravel on Windows

Installing PHP, Composer and Laravel on Windows

This is a start-to-finish, detailed installation guide on how to install PHP, Composer and Laravel on Windows, given that in just about every guide I've read, there's either steps missing or only partial instructions that still require an assumed level of knowledge of PHP and operating systems in general to complete.

So let's begin.

Installing Visual C++ Redistributable

Chances are you already have Visual C++ Redistributable installed on your PC, though if not, download and install the following package to satisfy the dependency requirements of running PHP:

Download Visual C++ Redistributable

Download Visual C++ Redistributable (64-bit)

Download Visual C++ Redistributable (32-bit)

Visual C++ Redistributable has an installer wizard, so basically offers a "Next, Next, Next" installation.


Run the installer and you should see the following. 



Tick the tick-box next to "I agree to the license terms and conditions" which will enable the Install button so you can proceed to the next step.

Click Install.

Error messages

If you get the following error message, chances are you already have Visual C++ Redistributable  installed, so you should be able to cancel this part of the installation and move on to the next section of this guide.

Installing PHP

Now we've got installation of Visual C++ Redistributable out of the way, we need to install PHP.

Proceed to the following website and download the latest version of PHP. At the time of writing the latest version is 8.2.3.

Download PHP 8.2.3

Click the following link, which will download the latest version of PHP.

Download PHP (latest version)

Following is a screenshot of the PHP website. 

We want to download the "Zip", "Non Thread safe version".


Extract the PHP files

Extract all files from the downloaded zip into C:\php.

A trap for young players is to ensure that your extracted files ended up in C:\php\, rather than in a sub-folder (e.g. c:\php\php-8.2.3-nts-Win32-vs16-x64\)

If you've extracted your files like the following screenshot so your PHP folder has a sub-folder with the version number in that folder name, it means your core PHP path will be incorrect for the next steps of this guide and you'll need to manually copy the files up one folder, so they reside in C:\php.




Whilst I've written "WRONG!" above on the placement of the files, to keep things simple for this instruction guide, you could in fact keep the "wrong" structure, as long the upcoming steps in relation to Environment variables and Composer paths are set the same as the location of your PHP extraction path.

As a brief example, for more advanced programmers, you may have a C:\php\ folder with all different versions of PHP installed on your development PC for different projects that may use different versions of PHP, though rather than digress too far from the purpose of this guide, which isn't to set up and run different versions of PHP side-by-side, I'll stick to my guns and stand by my "wrong" statement.  

Checking extraction of PHP is now accessible at the command line

So, now that we've extracted the files into our PHP root directory, we want to test PHP to make sure the PHP commands work from the command line. 

From your Start menu, let's open a command prompt:


Open a command prompt by typing the following in your search and pressing <Enter>:

    cmd

Now we want to check our PHP is working, so from your command prompt, type the following:

    php -v

Install PHP Composer

Now that we have PHP installed and functional, we next need to install Composer.

Installing Composer is simple; here's how!

1. Download Composer from the following link:

Download PHP Composer

Make sure you issue your command with a capital V, otherwise you'll instead see the following:


Now that we have our base environment set up and composer is functional, we can create a Laravel project.

Let's create a folder for all of our Laravel projects.

I'm going to create a folder named Projects in the root C:\ drive, so it's easy to find.

From our command prompt, issue the following commands, which will take us to the root level of the drive (C:\), followed by creating a project folder named Projects:

    cd \

    md Projects

Now we're going to go into our Projects folder and create a basic Laravel project named Project1.

So, issue the following command to go into our newly created Projects folder:

    cd Projects

Then we issue the following command, which will create the project and note that the Laravel project creation folder will create the Project1 folder as part of the project creation.

    composer create-project laravel/laravel Project1

So our project is now being created as can be seen in the above screenshot.



If you get any errors about dependencies, it is likely that you'll need to enable certain extensions within your PHP configuration, though don't panic, it's pretty simple to do.

So my errors telling me that we're missing the fileinfo extension, as follows:

From our Start menu, type "notepad.exe" in your search, which should return a search result of Notepad in the results:





Now that Notepad is open, go up to your File menu, and select "Open" as pictured above.

Browse to your C:\php folder; we also need to change our file type to "All" given that by default Notepad will only normally show Text files (*.txt).



Now that we can see all the files, we want to select and Open our php.ini file.



The next step is to find the line in php.ini that relates to the requested dependency we need to enable, fileinfo.

So press Ctrl+F to open the find in Notepad, type in "fileinfo" and press Enter. You should see the word "fileinfo" highlighted on the screen.



Now we simply need to remove the ";" from in front of the ;extension=fileinfo and save the file.

Now that this is done, we should be good to create our project.

When you run the composer command again, if you get an error about the project directory not being empty, simply delete the entire Project1 folder and run the composer command again from the C:\Projects folder.



So the command we want to issue from the C:\Projects folder is as follows, which will delete your Project1 folder:

    rd /S /Q Project1

    


Now let's run the composer command again, and this time you should see the following, which is Composer downloading the Laravel project framework files and folders needed:




At the end of the process you should see the following:




You should now have your first Laravel project downloaded and set up.

Remember, that you're not presently in your Project1 folder, so we need to change directory to our new Project1 folder now, after which we can start our local web server to test our Laravel project.

    cd Project1

As you can see below, I tried to start my server outside of my project folder, then started the web server from within the actual folder.




So we've now run our php artisan serve command to start our web server, which tells us the address of where our Laravel Project1 project can be viewed via a web browser (using your favourite browser, i.e. Chrome, Firefox, Safari, Opera, etc.).

Just remember we're not running the web server on port 80, we're using port 8000, so be sure to include :8000 at the end of your web address.



There you have it, how to install PHP, Composer and Laravel, including some common errors and tips to correct them.
Name

false
ltr
static_page
Tech Lab: Installing PHP, Composer & Laravel on Windows
Installing PHP, Composer & Laravel on Windows
How to install PHP 8.2.3, Composer 2.5.4 & Laravel 10
Tech Lab
https://techlab.connektiv8.com/p/installing-php-composer-laravel-on.html
https://techlab.connektiv8.com/
https://techlab.connektiv8.com/
https://techlab.connektiv8.com/p/installing-php-composer-laravel-on.html
true
5093225316588518036
UTF-8
Not found any posts Not found any related posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU Tag ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Contents See also related Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network