Skip to content

JacquesDurand/oc-blog

Repository files navigation

Security Rating Maintainability Rating Vulnerabilities Bugs
SonarCloud

Parcours OpenClassrooms: Développeur d'application PHP/Symfony

Projet 5: Créer un blog en PHP


Description

The goal of this project was to create a blog from scratch in a recent version of PHP without the use of any framework ( nor front neither back).
It had to contain:

  • A minimum of the following entities:
    • Some Users
    • Some blog Posts
    • The possibility to leave a Comment on a blog post
  • A front office with:
    • An index
    • A navigation menu
    • Pages for a single/multiple blog posts
    • Forms to:
      • leave a comment on a post
      • contact the Admin (myself)
      • register/login as a User
  • A back office with:
    • everything needed to manage the CRUD (Creation, Update, Read, Deletion) of each entity

NOTA BENE :
The back end has been realised in PHP 7.4.
The front end has been realised through the use of Tailwind CSS and a tiny bit of Vanilla Javascript

Table of contents

Installation

Prerequisites

Git

To be able to locally use this project, you will need to install Git on your machine.
Follow the installation instructions here depending on your Operating system.

Docker

This project runs 3 separate applications each in their own containers:

  1. The PostgreSql DataBase
  2. The Nginx Server
  3. The PHP application (blog) itself

Each is based upon its own Docker Image.
To have them run locally, you will need to install Docker on your machine.
Follow the installation instructions here for most OS or here for Archlinux.

Docker Compose

As defined on the documentation:

Compose is a tool for defining and running multi-container Docker applications.

Since it is our case in this project, we also chose to use compose to build the complete project.
You can see how to install it here

Clone

Move to the parent directory where you wish to clone the project.

git clone https://github.com/JacquesDurand/oc-blog.git

Then move into the newly cloned directory

cd oc-blog

Configuration

This project relies on the use of environment variables, which act as secrets. These are for instance the database connection information.
To prevent sharing my personal information, I didn't commit the .env file where they are contained.
I did commit a .env.dist where you can find the variables needed to launch this project.
Once inside oc-blog directory:

cp .env.dist .env

Then open your newly created .env with your favorite text editor and replace the different " CHANGEME" values by your own.
You might want to keep

DB_PORT= 5432

since the postgres image will run on this port.
Here is an example of .env for this project:

DB_HOST= 'db'
DB_PORT= 5432
DB_NAME= 'mydb'
DB_USERNAME= 'myUser'
DB_PASSWORD= 'myPassword'
MAIL_TO= '[email protected]'

Where:

MAIL_TO

is your mail for receiving messages through the blog's contact form.
Be aware though that for this form to really send you email, the machine where you host your project must have an SMTP server ready.

Getting Started

Now that everything has been configured, let us get into it !
Still at the root of oc-blog, run :

docker-compose up -d

If everything went fine, you should be able to navigate to localhost and start looking around my blog.
If not, please do not hesitate to submit an issue and I'll get back to you ASAP.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages