Phase 1 – Installing Laravel

Phase 1 – Installing Laravel

I followed the following steps to create my app. And because they are too many steps; I split them into 5-6 posts each prefixed with Phase X – then the phase name.

I will document here all the process including any obstacles or issues and how I tackled them.

Step1. Installing Laravel

Prepare the scenes

By the time of creating my app, it was Laravel version 6 which requires PHP version 7.2 or higher, and MySQL for the database.

The plan was to install my Laravel app within XAMPP environment and make it portable so it will be easy for me to move between university and home during the development stage.

And then to upload the files to a commercial web server and transfer the database for the production stage (the marking stage in our case).

So I installed a fresh XAMPP setup in my pen-drive, created a new subdirectory inside the file-root to hold all my Laravel projects and I configured Apache to accept read/write from/to that directory.

Composer Dependency Manager

Laravel uses Composer as a dependency manager like npm or yarn for NodeJS.

I installed Composer globally on windows and also I copied the file composer.phar into the PHP folder within XAMPP and to run it from any project’s folder right from the command line CLI; I created a new batch file inside /XAMPP/PHP directory called composer.bat with the following content:

@ECHO OFF
php "%~dp0composer.phar" %*

This line tells Shell to run -> PHP -> composer.phar automatically every time we call composer command within the CLI.

Create a new Laravel project

Now it is the time to create the new Laravel project by using composer, I just navigated to my new empty directory using XAMPP Shell and typed in the following command:

composer create-project laravel/laravel app2

This will take care of installing the Laravel project boilerplate, the basic files and folders to start with our app.

Configuring the DocumentRoot directive in Apache file server

The last step in this phase was to configure my file server to serve the root directory of my Laravel project by default.

So, I edited my httpd.conf file to include the public folder of my app as the DocumentRoot directive and to allow accessing the files from outside by adding the following lines:

DocumentRoot "F:/xampp/laravel/app2/public"
<Directory "F:/xampp/laravel/app2/public">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

After restarting the server, our root directory from now on in XAMPP’s is the localhost or http://localhost:8080/ in my case (with an 8080 port).

Artisan.bat

Similar to what we have done before and been able to use Artisan helper from outside of the project folder, so I created a new batch file inside /PHP folder called artisan.bat and included the followings.

@ECHO OFF
php "%~dp0../Laravel/app2/artisan" %*

References