Prerequisites#
We have to install the necessary requirements before getting started.1.
Enable virtualization in your BIO. Every hardware varies so there is no exact step to step guide on this. If you need help enabling virtualization on your PC, ask the I.T. team for help. 2.
Install Git for Windows. The reason that we have to install git for windows is to use its built-in Git Credentials Manager which is where we store our git account details later on. 5.
Install Docker . Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. 6.
Install Hosts File Editor (Optional) Software that will help us create custom domains locally admin.dothis.test which basically just points to 127.0.0.1. We will learn the use of this in the instructions below. 7.
Install Ubuntu We will need this to easily access WSL using this distribution. 8.
BitBucket Account\ Make sure you have created a bitbucket account and have access to the repositories. If you don't have one yet, please seek assistance from your supervisor.
Repository#
First, you have to clone the project from bitbucket:Please make sure to replace YOUR_USERNAME with your actual username on BitBucket.
Make sure you are in the project's directory, if not yet then execute the command below:
Preparation#
Before the installation we must setup our machine first to be ready on the installation.1
Update the services and packages
To get the list of all upgradable services, run this command:
To install the services that can be upgraded, run this command:2
Install Git for WSL
To clone projects or use git commands, we need to install Git in WSL. Run this command:
To set up your Git config file, open a command line for the distribution you're working in and set your name with this command (replacing "Your Name" with your preferred username):Then, this time we will use the Git Credential Manager that we have installed on Windows.3
Install Node JS
For us to use the npm package modules on different projects, we have to setup node.js in WSL. First, we have to install curl that will allow us to download the installer of node.js
Execute the command below to download nvm:Then, to install node.js, execute the command below:4
Install MySQL
Later on, we will use the MySQL client to connect with the docker MySQL instance, from there it will help us access the database within the docker container.
5
Creating a directory for all of the projects
In preparation of cloning the projects in the local machine, we have to create a place where we're going to put all of the project repositories. To create a new directory, let's say we want to name the directory as dev-apps, follow the command below:
Let's make sure this directory will allow us to perform read/write operations.Then, we have to add the ownership of the directory to the current Unix username:6
Create App Password in BitBucket
Unlike the traditional way, Git now offers a modern authentication method of handling repositories, it recommends having app passwords instead of using account passwords for an additional security layer and attaching specific abilities/permissions on each password you create. To do this we have to access BitBucket in your favorite browser.
1.
Open your account settings here.
2.
From the sidebar on the left, click App Passwords.
3.
You'll see a Create app password, click the button and set the read/write permission for the following 4.
Then press Create button.
5.
When a dialog shows up, copy the password and paste it on a notepad
Do not lose the created password as we will use it to clone the projects later on.
Project Set Up#
At this stage, we have to use docker to install the necessary services like mysql, php and others. To do this, follow the command below:Step 1 - Install the dependencies#
We have to use docker to install the necessary services like mysql, php and others. To do this, follow the command below:Then, in order for us to use sail easily, we have to add it on ~/.bashrc. First we have to edit the ~/.bashrc file by executing the command below:Then, when vim will show the contents of the file, navigate the cursor at the very bottom by clicking arrow downTo edit or make changes, just press the i key from your keyboard.
Paste the code presented below at the very bottom of the filealias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
To save the changes, press the key esc then press shift+; and finally, write wq that means "write" and "quit".Step 2 - Creating an .env file#
Before running the sail, we have to create an env file first by executing the command below:Then make sure to change the values based on the code belowCACHE_DRIVER=array
QUEUE_CONNECTION=redis
Step 3 - Running Laravel Sail#
To initialize the services in docker, we have to run laravel sail first to let docker install the needs of the project.It is normal that at this stage it will take sometime to finish installing, just be patient.
Then, let's initialize the Laravel key by executing the command below:Step 3 - Database Migrations#
Since we have now successfully set-up the MySQL, we can now migrate:Step 4 - Setting up Virtual Hosts#
Open the Hosts File Editor we installed earlier, Then add the following to the registryStep 5 - Database Seeding#
To ensure all of our changes are appliedsail artisan optimize:clear
Then we can now execute the command that will initialize your local development machine with dummy accounts that you can use:You have now successfully set up the project.