Creating My PHP Blog: Step-by-Step Guide

Table of Contents

Overview

This guide documents the creation of my PHP blog over two days, detailing each step of the process.

Day 1: Project Setup

Step 1: Initial Setup

  1. Create a New Directory:
    • Create a folder for your project and name it as you wish blog_project(example):
    • Run the command in your terminal:
      mkdir blog_project
      cd blog_project
    • Inside the blog_project folder create subdirectories to organize your code:
      mkdir .docker
      touch .docker/Dockerfile
      touch docker-compose.yml
      mkdir assets
      mkdir assets/css
      mkdir assets/images
      mkdir assets/js
      touch assets/css/style.css
      touch assets/js/main.js
      mkdir src
      cd src
      touch index.php
      touch about.php
      touch blog.php
      touch send_emails.php
      touch subscribe.php
      touch unsubscribe.php
      touch subscribers.txt
      mkdir md
      mkdir templates
      touch templates/header.php
      touch templates/footer.php
    • .docker folder will contain your Dockerfile
    • docker-compose.yml will define your Docker containers
    • assets folder fill contain your css, js file and images folder
    • src folder will contain all your PHP code and HTML files
    • index.php will have your main page code(what user will see when he goes to your website)
    • about.php will have your code for about page
    • blog.php will have your code for displaying of your post cards and your post markdown textes
    • send_emails.php will contain your email sending code
    • subscribe.php && unsubscribe.php will handle your subscribe and unsubscribe functionality
    • subscribers.txt will contain emails of your subscribers for weekly or bi-weekly emailing
    • src/md will contain your posts markdown texts
    • templates will contain your header and footer file that you can include in all your pages

Step 2: Initialize Git Repository

2.1 Initialize Git in Your Project Directory:

2.2 Add the GitHub Repository as a Remote:

2.3 Add Your Project Files to Git:

Step 3: Lets go with Coding

3.1 Dockerfile:

3.2 docker-compose.yml:

3.3 Start the docker:

3.5 Main Page: