The following tutorial will guide on setting the Laravel PHP Framework in windows machine. If this the first time you are hearing the term Laravel, then consider should reading the following article to understand and know more on Laravel. Here are some links that introduces the Laravel PHP Framework:-
Intro to Laravel PHP Framework
An Introduction about Laravel Framework
Goodbye CodeIgniter, Hello Laravel
A beautiful PHP framework that does not make me feel stupid
The tutorial will guide on installing and setting the web-server to up to the Laravel PHP Framework installation. The guide is separated into several stages in which you need to complete each stage before moving to other stage. In total there are 6 stages as listed below:-
Stage 1 – Installing XAMPP
This stage will guide on setting up a web server in your machine. The web-server used in the guide is XAMPP. It is a bundled web-server and comes pre installed with Apache, MySQL and PHP.
- Navigate to the XAMPP’s download page and grab the latest copy of the XAMPP server here.
- Download either the installer or the portable version and perform the installation. Please follow the onscreen installation if you downloaded the installer version or extract the folder on the C:\xampp path if you have downloaded the portable version of XAMPP.
- Once installed, your XAMPP server should be available in the default path at C:\xampp. You can also install it on your preferred path.
- In the following guide we will assume that the XAMPP has been installed at the following path “C:\xampp”. Navigate to the following folder C:\xampp\apache\conf and open the httpd.conf file in text editor. Find the line below and un-comment it.
#LoadModule rewrite_module modules/mod_rewrite.so
change to
LoadModule rewrite_module modules/mod_rewrite.so
- Save and close the file once the changes has been made.
- Execute the ” xampp-control.exe” located on the root folder (C:\xampp) of your XAMPP and start both your APACHE and Mysql module.
If you have completed all the six steps above, then you have successfully installed XAMPP in your machine. Verify the installation by going to http://localhost in your browser and you will be greeted with XAMPP welcome page.
Stage 2 – Setting MYSQL Authenication Details
This stage guides on setting up the user authentication credentials for the MySQL server running in your machine. If you prefer not to set the authentication credentials then can skip this stage and moves to stage 3.
- Once the server started, navigate to the following URL http://localhost/security/index.php to set the username and password for your MySQL server.
- Once the credentials set, you can move on to stage 3.
Stage 3 – Setting PHP variable Path
The PHP variable path should be set on your machine in order to execute the Laravel’s Command Line Interface tool know as Artisan.
- Locate MyComputer either on your desktop or from the start menu. Once located, right click and go to the properties.
- A new window will load with the computers configuration details. In the window, locate the advanced system setting from the left sidebar and click it.
- Another window with “System Properties” title will load. In this window located the button Environment Variables on the Advanced Tab. Click the Environment Variables and further to the next step.
- In the Environment Variable window, there will be a list with the title of the “System Variables”. Within the list, look for the variable labelled as PATH and edit it.
- Append the following path at the end of the values C:\xampp\php. Use the ; to separate from other variable. Important, append the path and do not replace the existing variables.
- The PHP path is set and you can check running the following command at your command prompt php -v. This will display your current version of PHP installed in the machine.
- Next run the following command in your command prompt php -m. This is to check the modules that are enabled within the PHP in your machine. A list of modules will be displayed once the command executed successfully. Check whether the MCrypt module is enabled. If not then move to Stage 4 to enable the MCrypt in your machine.
Stage 4 – Enabling MCrypt Module
By default the MCrypt extension comes pre-installed and enabled in XAMPP. If it is not enabled, follow the steps below to enable it in your machine. The MCrypt extension is a prerequisite configuration for Laravel PHP Framework.
- Navigate to the following path C:\xampp\php in you machine and located the php.ini file.
- Once the file has been located, open it in your preferred text editor and search for the Dynamic Extensions section in the php.ini file.
- Add the following line extension=php_mcrypt.dll at the end of the section to enable automatic loading of the MCrypt extension.
- Restart your Apache and issue the php -m command in command prompt and check if the MCrypt have been enabled.
Stage 5 – Installing Composer
Laravel utilizes Composer to manage its dependencies. All the dependencies can be installed and updated through the Composer.
- Navigate to the Composer’s download page here and grab the latest build of the Composer for windows machine.
- Once downloaded, execute the installation file and complete the on screen instruction. The installation will detect the PHP version installed and also add the system path by itself. Manual configuration is not required.
- After completing the installation, run the following command in your command prompt composer -V to check whether the composer is successfully installed in your machine.
Stage 6 – Setting Up Laravel
- Open your command prompt and change the path to C:\xampp\htdocs by issuing the change directory (cd) command.
- Once you are within the root of for web directory, run the following command:-
composer create-project laravel/laravel --prefer-dist
from your command prompt to download the latest copy of laravel from repository
- The composer will start executing and download all the required files. Once the download is completed, there will a new folder labelled as Laravel within your htdocs folder. This is where all the Laravel’s PHP Framework files are placed.
- Next run and access the path from your localhost using the following url http://localhost/laravel/public and you should be greeted with the Laravels default page.
Done, the Laravel PHP Framework installation completed successfully !