Today I decided to take a crack at setting up a Laravel environment on my personal machine. I did a tiny bit of Laravel coding at my previous job, but I wanted to build something from scratch that I could use for a portfolio project. I found a good tutorial on YouTube, but two hours after starting I was still only 8 minutes into the video. I missed a critical step, and I kept running into issues. In the end everything was super easy to fix, but I'm documenting the setup process for future reference, and hopefully this will save someone else some grief as well.
As a disclaimer, I'm on Windows and using the latest software releases as of Jun 2019. Mileage may vary.
First thing to do is download and setup PHP. I downloaded version 7.1.30.
Next create a folder where you want PHP to live. I created mine at the root of C the drive.
After the PHP file has downloaded, extract the contents of the zip file to your new folder. And add the folder location to your PATH
.
Next copy/rename the php.ini-development
file to be called php.ini
. It's very important that this file exists.
In the newly created file configure the extensions by searching for and un-commenting these lines of code:
extension_dir = "ext"
extension=openssl
extension=mbstring
extension=fileinfo
The first two lines of code above solve the following error when trying to install Laravel via Composer:
[Composer\Exception\NoSslException]
And by modifying the ini
file to include the necessary extensions this should prevent composer from trying to modify the file during install.
Next install Composer. For me downloading the exe
and installing with accepting the defaults was sufficient.
After Composer is installed run:
composer global require laravel/installer
Then you should be able to run:
laravel new myFirstProject
And hopefully you will be free from errors. If you do encounter any errors it's likely an issue with the ini
file and missing extensions.
I know that this installation process is very trivial and hardly in need of a guide ( and there are probably better ways to get setup). But being new to the world of PHP the setup process was a bit foreign to me and I managed to get hung up for bit. Hope this helps someone.
Top comments (2)
Thanks. I want started learning Laravel, but I'm Mac user. Do you have a link about nice courses about Laravel?
I was following this tutorial on youtube. It does require some PHP knowledge but the instructor is using a Mac. The tutorial also uses Vue.js for the front-end.
This tutorial on udemy seems really good and the website is built using PHP blades for server-side rendering.