/php-fullstack-app

A full stack php application that manages user authentication, registration, login and even password forgotten.

Primary LanguagePHP

Php Fullstack App

A full stack php application that manages user authentication, registration, login and even password forgotten.

Technologies/tools/languages used :

php-logo postgresql-badge php-logo php-logo php-logo php-logo php-logo

Table of contents

Overview

This project is initially an exercise to practice Php, Ajax, Tailwindcss, Typescript and sass in a real life application like. It has 3 major pages:

  1. Login page ๐Ÿ”‘
  2. Register page ๐Ÿ‘ค
  3. Home page ๐Ÿ 

As database, for the registration, login, and other utilities, I used PostgreSQL. On the home page, I added my main projects I built when I was learning JavaScript :

  • Space Calculator ๐Ÿš€
  • Comprehensive Weather app โšก๐ŸŒž๐ŸŒช
  • Full snake Game ๐Ÿ
  • Tic tac Toe โญ•โŒ
  • Shifumi game โœŒ๐Ÿ–๐Ÿ‘Š
  • Images slider ๐Ÿ–ผ
  • Dynamic Stopwatch โฑ
  • New York Simple Clock โŒš
  • Classic To do List ๐Ÿ“‹

Because I used tailwindcss CLI, I put SASS in the project for a more pragmatically way to write CSS (especially mixins)

Login Page

A fully responsive login page with a purple design.

small-screen-login-page-image large-screen-login-page-image
lighthouse-score

Login Page : Features

  1. This page have two many fields :
    • Username
    • password (has hide/show password)
  2. A forgot (link to the forgotten password section) password link that lead to another page to reset the password
  3. A link to send the user to the register page if he is not registered yet

Register Page

As the login page, it is also responsive and will adapt depending of your screen.

small-screen-register-page-image large-screen-register-page-image
lighthouse-score

Register Page : Features

  1. Here, three fields:

    • Email address
    • Username
    • Password (at least 8 characters) and also hide/show ๐Ÿ‘ option
  2. A link to the login page if the user has already signed in

Home Page

Responsive (naturally). The purple design is kept.

small-screen-register-page-image large-screen-register-page-image
lighthouse-score

Home Page : Features

  1. A navbar that will change depending of the screen you have.It has 5 tabs :

    • Home ๐Ÿ 
    • Profile ๐Ÿ‘ค
    • Tools โš™
    • About
    • Log out

On big screens (width >= 640px), it will be a normal navbar horizontal.

horizontal-navbar-image

On small screens, it is a menu burger that displays a vertical navbar.

vertical-navbar-image
  1. The main title has an animation of cursor typing. It loops infinitely
lighthouse-score
  1. A bouncing button that leads to the project grid
  2. Project grids : all my JS projects are displayed as a grid of card.
small-screen-grid-tools-image large-screen-grid-tools-image
  1. A logout button. It opens a dialog that ask the user to confirm the logout
  2. A "back to top" button able to scale depending of the user's screen width.

Profile Tab

This tab is quite special, it will open a dialog that make a brief recap of the user current stats. Here are the stats shown :

  • Username
  • Number of visits : this counter will increment each time you visit the main page
  • Best Score at snake game
  • Best Score at Rock-Paper-Scissors game (shifumi)
  • And also the date
profile-dialog-image

Log out Tab

It behaves exactly like the logout button at the bottom of the page

Space Calculator ๐Ÿš€

space-calculator-image space-calculator-image

A calculator with a good-looking design that performs basic operations : addition, substraction, multiplication, division

As a personal touch, I added a clock on the top of the calculator (the clock).

If you click on it, it will change and display the date in DD/MM/YYYY format. Click an another time to go back to default state.

Comprehensive Weather app โšก๐ŸŒž๐ŸŒช

A readaptation of my weather app project on github(link). Enter the name of the city and GO ! A simple design with animated icons to add some style. List of all parameters rendered when you query a city :

  1. Location (city, town, ...) & Country
  2. Temperature in Celsius degrees
  3. Feels Like also in Celsius degrees
  4. Humidity
  5. Wind Direction
  6. Speed Direction
  7. Description (clear sky, rainy, foggy, ...)
  8. The date and time at the place queried
weather-app-image-night weather-app-image-day

Full snake Game ๐Ÿ

A complete snake game with many features. You can choose one between three levels of difficulty : easy, normal and hard

snake-start-dialog-image snake-game-in-game-image

Here, audios are integrated. Different sounds will play (start, movement, eating, lose). If you lose, an another dialog will open

restart-snake-game-dialog-image

And ask you if you want to replay. Your best score will be registered, store in the database and shown, as I mentioned before, in your profile dialog. It is not responsive, so you need a screen at least 600 px large.

Tic tac Toe โญ•โŒ

Tic tac toe game, but with swipe SFX. Play and admire the bright city behind you.

tic-tac-toe-game-image

This game need two players. When one of them wins, a dialog will popup and ask for retry or quit the game.

Shifumi game โœŒ๐Ÿ–๐Ÿ‘Š

Rock Paper Scissors game against the Computer. Purple design is back.

tic-tac-toe-game-image

The rules are simple : to win, your score must be higher than computer's score. You can stop a any moment by pressing the "Quit game" button. A dialog (another one) will popup and ask you to confirm.

Similarly to the snake game, your best score will be registered in the database and shown on the home page in the user's profile

Images slider ๐Ÿ–ผ

Welcome in my short collection of city images.

large-screen-images-slider-image small-screen-images-slider-image

You can stop the scrolling effect by clicking on the admire button. To navigate through the slider, you can use the arrow buttons or directly the LEFT and RIGHT arrow key. This project is fully responsive.

Dynamic Stopwatch โฑ

A stopwatch with three (3) main options:

  • Start
  • Pause
  • Reset
stopwatch-image stopwatch-hover-image

Lighting effect when you hover the clock image.

New York Simple Clock โŒš

A simple clock that display :

NYC-clock-image
  • current time code HH:MM:SS and you can add the milliseconds
  • A greeting depending of the moment of the day
  • The date on, the format DayOfWeek Month Day Year
  • an option to show or hide milliseconds

Classic To do List ๐Ÿ“‹

The classic

To-do-list-image

Forgotten Password Management

On the login page you have the option Forgot password

forgotten-password-image
Click on it and you will be redirected to a page that asks you your email address. Provide it and submit. You will receive an email Friedrich Corner that gives you a code to reset the password.
code-submit-image

After entered the right code, you will be redirected to the last page that needs the new password. Confirm it and submit.

reset-password-image

You will be back on the login page. Congratulations, your password has been reset.

Installation : Run locally

You can run the project locally. Start by cloning the repository with the command :

  git clone https://github.com/Friedrich482/php-fullstack-app.git

After install the npm dependencies via :

  npm install

Also install php on your local machine.

You will need a local server. Because it is PHP, I recommend you applications like MAMP or XAMPP. They will install a local Apache Server to serve the project. Personally I prefer MAMP.

After that, you also need PHP dependencies installed via Composer. Install them with the command :

  composer update

Then run by opening the login folder and open the login.php file.

Environment variables

If you are running the project locally, you will need to create two .env files based on the .env.example files in the login and the include folders.

  • login folder :

        mailUsername = "example@gmail.com" # The email address goes here
        mailPassword = "xxxx xxxx xxxx xxxx" # Your code for smtp server
        mailAddress = "example@gmail.com" # The email address also goes here
        mailName = "example Example" # Your email username
    

I need to add some precisions here. In fact, I used the PHPMailer package in order to send mail for the reset password option. To run in local, you'll need tour own SMTP Server. Create one using Gmail. And fill the template with the data specified.

  • include folder :
     dbServer = "localhost"
     dbUser = "postgres" # This is the username by default with a postgres database
     dbPass = "password" # The password for your database goes here
     dbName = "users_data" # The database name, I named it users_data

And also there is a apiKey.example.json file in the projects/fetch-weather-app

{"API_KEY" : "YOUR_OPENWEATHER_MAP_API_KEY"}

I used a key from openweathermap.org. So to run locally, you'll need your own key. Go there and subscribe (it is free) to get yours. After come back and just rename the apiKey.example.json into apiKey.json and paste your API key inside.

Database shape

You need to have postgreSQL installed. Create a database called users_data. After that you'll need to create a table called users I put the .sql file in the database folder

Project Roadmap

  • Add a forgot password ๐Ÿ”‘

  • I need two pages here :

    • The first one to ask the email to the user
    • The second one will be a page to say him that a mail has been sent to him and to check his mails. He will now fill
    • two fields and pass only if the two passwords matches.
  • Inside the forgot password, I will ask your email address

  • Then send a random number with 6 digits (so between 100000 and 999999)

  • The user will enter that number and will pass only if the number matches. After that the number will be put to zero in the DB.

  • For the registration, I will do the same thing.

  • a nice animation to the welcome message ๐Ÿ‘‹ when logging or registering. It needs to be multicolor and chars will display one after the other

  • a navbar (if possible) on the home page

  • the tools will be classified by category : game ๐ŸŽฎ, weather app โ˜€, calculator ๐Ÿ–ฉ, to do-list, and so on

  • All the games and utilities as flex grid ๐Ÿ’ช elements (and their behavior should be responsive) (Here improvements are coming )

  • a different page for each tool

  • the background image may change depending of the moment of the day : sunrise ๐ŸŒ…, day โ˜€, sunset ๐ŸŒ‡, night ๐ŸŒ™ (canceled)

  • The counter of visits will be attached to an other element (possibly the navbar, and so it will no more be so messy positionned)

  • I should think to make the footer ๐Ÿฆถ mobile (animation ๐ŸŽž)

  • display the time in the navbar, eventually

  • The time will now appear in the Profile tab.

  • the to-do-list must use the LocalStorage

  • For the log out, a dialog ๐Ÿ’ฌ should pop up ( maybe a blur effect will be interesting, in background )

  • The navbar should contain profile with infos about user, tools ( in many sections ) and logout

  • The infos like counter of visits will be in Profile

  • The "go back to top" button may be set as fixed element, so it will display at the bottom of the page as soon as we quit the top

  • If we click on the DOM elements that have the notification ping, it disappears and for the Profile sections, a dialog ๐Ÿ’ฌ will open and display infos about the users

  • If the user has already checked the one of the ping elements(especially the logout elements for the small and large screens navbars), if he reduce or increase the size of his screen and so, for example the display for small or large sreens occurs, the ping WILL NO LONGER BE PRESENT

  • Added the simple calculator file

  • Add Typescript instead of vanilla JavaScript for the calculator

  • Add Typescript instead of vanilla JavaScript for the home page

  • Correct all the errors for the home.ts page

  • Now the next mission is to add ts for the login page

  • And correct all the (potential) errors

  • And after that the register page

  • And there too, fix every single squiggled line

  • Now it is the turn of the weather app. This is probably the biggest ๐Ÿ’ช refactor of all

  • Firstly, let's use tailwindcss in the project

  • And after typescript

  • By the way refactor the structure of the page for a better experience

  • Turn of the snake game

  • Much easier because it has less code

  • The same : tailwindcss first

  • And after typescript

  • Disable the buttons on the the when the player is focused on the game. What I want to say is that if the game starts, the movement buttons can't interact with other parts of the page

  • Open a dialog when the player arrives to ask him level of difficulty. They will be ranked in :

    • easy
    • normal
    • hard ๐Ÿ’ช
  • For each level of difficulty, the speed of the snake will increase. Add that into the setInterval method by changing the snakespeed

  • While the player restarts the game and the countdown is displayed, the restart button (Enter key or Restart Button itself) must be disabled to avoid time intervals overlapping

  • My other idea is to play a song when:

    • You lose
    • You eat a food
    • You change direction
    • Game over
    • [] You beat your own high score (PHP needed)
  • Now the Tic Tac Toe Game...

  • As always tailwind CSS first

  • And after TypeScript

  • Maybe here too, I will add sounds ๐ŸŽต

  • The 5th project is the shifumi game. Also not too much code...

  • Tailwind CSS

  • TypeScript

  • After the images slider project

  • Tailwind CSS

  • TypeScript

  • The stopwatch is the following project

  • Like always:

    • Tailwind CSS
    • Typescript
  • New york clock : all the habitual stuff

  • To do list : the same thing here

  • improve LightHouse score on each single page of the app:

    • replace the rocket gif image by another one
    • replace all images by their .avif of .webP version
  • The app will be deployed by default on vercel

  • Todo : add the lighthouse score for the main pages

This list will be updated depending on my progression through it.