Laravel Makefiles

Author: Emad Zaamout

Sunday, Oct 24, 2022

Table of Contents

  1. Introduction
  2. What is a Makefile and how does it work?
  3. Installation
  4. Setting up project
  5. Create a Makefile
  6. Makefile PHONY & Creating targets

Introduction

Welcome back,

In this course, were going to learn how to build Makefiles.

A common problem you will always face when working on any project, is how to build and work with your project. By using Makefiles, you can forever change how you build your projects.

Stop wasting time running your commands manually. Its not efficient. Today you might remember all the commands you need to build your project. Few months down the road you will forget all of them.

For this course, we will be using docker. If you’re not using Docker, you can still follow along. The important part is for you to know how to create make commands.

If your completely new to Docker, I highly recommend you watch my other videos relating to building docker for Laravel.

What is a Makefile and how does it work?

Makefiles provide a simply way to organize code building processes.

For example, if you’re using docker, and you have all your containers up and running, then what would you do, if you wanted to delete all your containers and volumes, and recreate everything?

You would have to manually run the following commands:


          # Stop Containers
          docker compose -f docker-compose.yml down

          # Delete Containers
          docker rm -vf  php
          docker rm -vf  node
          docker rm -vf  database

          # Delete Volumes
          docker volume rm laravel-blog_db-vol
        

A Makefile would make it so instead of you running each docker command manually, you run a single make command instead, that will do all that for you. For example: make destroy

The problem with running commands manually is it can be time consuming. It also opens room for errors. And anyone can easily forget or not know which command to run.

The idea of Makefiles is to pretty much to centralized and contain all your build commands.

Installation

Before you attempt to install make, make sure that you don’t already have it installed.

Open your terminal and run the following command: make

If make is installed, you should see this error:


          make: *** No targets specified and no makefile found.  Stop.
        

If your on Mac, you can use brew to install make.


          brew install make
        

If your using ubuntu or linux you can run


          sudo apt-get install build-essential
        

Setting up project

Inside your WSL, create a new folder for our project. Call is laravel-blog. Go ahead and pull our blog implementation project from github:

https://github.com/emad-zaamout/laravel-9-complete-course-blog-implementation

For this project, I already provided you with all the docker files and builds that you need in order to run the project. For this course, we will create a standard Makefile template that we can use for all our future projects.

Create a Makefile

Inside your project root directory, create a new file, and name it Makefile. Now in your terminal, if you run `make` you should see the following error:


          make: *** No targets.  Stop.
        

In Makefiles terminology, a target is a command. This error says there are no targets inside your makefile. By default, when you run the make command, Makefiles will always execute your first defined target.

Makefile PHONY & Creating targets

https://github.com/emad-zaamout/laravel-makefile-template/blob/master/Makefile

Other Posts

Windows WSL 2 Docker Tutorial Course Image

Tuesday, August 22 2023

Deploy any Dockerized application using AWS Course

Author: Emad Zaamout
Amazon Elastic Container Registry (AWS ECR)

Tuesday, June 27 2023

Amazon Elastic Container Registry (AWS ECR)

Author: Emad Zaamout
Custom Docker Images Course

Tuesday, June 27 2023

Custom Docker Images

Author: Emad Zaamout
Laravel Makefiles Course Image

Sunday, Oct 24, 2022

Laravel Makefiles

Author: Emad Zaamout
Windows WSL 2 Docker Tutorial Course Image

Sunday, Oct 24, 2022

Laravel Docker Course

Author: Emad Zaamout
Windows WSL 2 Docker Tutorial Course Image

Sunday, Oct 24, 2022

Laravel 9 Complete Course | Blog Implementation

Author: Emad Zaamout
Windows WSL 2 Docker Tutorial Course Image

Sunday, Oct 24, 2022

Windows WSL 2 Docker Tutorial

Author: Emad Zaamout
GIT Crash Course using Bitbucket By Emad Zaamout

Saturday May 1, 2021

Laravel Websockets Example Chat Application

Author: Emad Zaamout
GIT Crash Course using Bitbucket By Emad Zaamout

Saturday May 1, 2021

Laravel API Course | MVCS Repository Pattern

Author: Emad Zaamout
GIT Crash Course using Bitbucket By Emad Zaamout

Saturday October 24, 2021

Git Tutorial - Git Crash Course using BitBucket

Author: Emad Zaamout
What is AWS Elastic Load Balancer By Emad Zaamout

Monday October 18, 2021

AWS Elastic Load Balancing

Author: Emad Zaamout
DMARC SPF DKIM Course By Emad Zaamout

Saturday October 16, 2021

Email DNS Master Course - SPF + DKIM + DMARC

Author: Emad Zaamout
Email SPF Record Tutorial – Sender Policy Framework (SPF) | Prevent Email Spoofing | DNS Course By Emad Zaamout

Saturday October 16, 2021

Email SPF Record Tutorial – Sender Policy Framework (SPF) | Prevent Email Spoofing | DNS Course

Author: Emad Zaamout
DMARC Tutorial - How to set up DNS DMARC record | Protect Your Doman By Emad Zaamout

Saturday October 16, 2021

DMARC Tutorial - How to set up DNS DMARC record | Protect Your Doman

Author: Emad Zaamout
Git Hooks Crash Course

Sunday, September, 2021 (MDT)

Git Hooks Crash Course

Author: Emad Zaamout
Laravel CI\CD using AWS RDS EC2 S3 CodeDeploy BitBucket By Emad Zaamout

Friday, September 17, 2021 (MDT)

Laravel DevOps Tutorial - Laravel Deployment Automation CI\CD using AWS RDS EC2 S3 CodeDeploy BitBucket

Author: Emad Zaamout
Deploy any Laravel app in AWS (Amazon Web Services) By Emad Zaamout

Monday, April 19, 2021 (MDT)

Deploy any Laravel App in AWS (Amazon Web Services)

Author: Emad Zaamout
Fisher Yates Shuffle Algorithm Implementation? By Emad Zaamout

Saturday, September 26, 2020 (MDT)

Find out the secrets, tips and tricks to ranking number 1 on Google.

Author: Emad Zaamout
Fisher Yates Shuffle Algorithm Implementation? By Emad Zaamout

Saturday, September 26, 2020 (MDT)

Fisher - Yates Shuffle Algorithm Implementation

Author: Emad Zaamout
What Is an Ecommerce Website & How to Get Started (2020 guide)? By Emad Zaamout

Saturday, September 26, 2020 (MDT)

What Is an Ecommerce Website & How to Get Started (2020 guide)?

Author: Emad Zaamout
5 Reasons Why You Need A Website Calgary Website Design Company AHT Cloud

Thursday, May 7, 2020

5 Reasons Why You Need A Website

Author: Emad Zaamout
Whats Involved in Creating a Unique Custom Website? By Emad Zaamout

Thursday, May 7, 2020

Whats Involved in Creating a Unique Custom Website?

Author: Emad Zaamout
SEO Checklist By Emad Zaamout

Thursday, May 7, 2020

SEO CHECKLIST

Author: Emad Zaamout

GET YOUR FREE ESTIMATE

CONTACT US TODAY FOR YOUR FREE CONSULTATION!


Contact us today to discuss your goals and we will create a simple roadmap to get you there. We look forward to speaking with you!

Main Office

Phone:   1 587-834-6567
Email:   support@ahtcloud.com
32 Westwinds Crescent NE #130
Calgary, AB T3J 5L3, CA

Products

TMS
Cloud Based Transportation Management System


Hours Of Operation

Monday 8:00 am - 5:00 pm
Tuesday 8:00 am - 5:00 pm
Wednesday 8:00 am - 5:00 pm
Thursday 8:00 am - 5:00 pm
Friday 8:00 am - 5:00 pm
Saturday Closed
Sunday Closed