This is a full-stack application built with PHP and MySQL. It is a simple client manager that allows you to add, edit, and delete clients and their addresses.
There aren't a lot of recent resources online when it comes to using pure PHP in 2024, so I wrote a blog post sharing the things I learned.
The application has the following structure:
public/index.php
is the application's entry point, where the autoloader is required and the application is started.src/Core
contains the application core, such as implementing the Router, Database, Renderer, etc.src/Handlers
contains the request handlers for the application routes.GET
requests call the handlerloader
method if it existsPOST
requests call theaction
method if it exists.- Handlers can also have a
render
method to render the HTML template.
src/Middleware
contains the middleware classes such asAuth
andGuest
middlewares for protected routes.src/templates
contains the HTML templates rendered with Plates.src/routes.php
registers the application routes and their handlers.src/utils.php
contains helper functions likedd
for debugging.
- Make sure you have Docker installed:
docker -v
- Start the application and the database with Docker Compose:
docker-compose up -d
- Open your browser and navigate to http://localhost:8888.
You can log in with the following credentials:
Email: john.doe@gmail.com
Password: 123456
- Make sure you have PHP 8.*, Composer, and Docker installed:
php -v
composer -v
docker -v
- Install the dependencies:
composer install
- Start the database with Docker Compose:
docker-compose up -d db
This command will start a MySQL database on port :3306.
You can also use a local version of MySQL, just make sure to update the .env
file with your database credentials.
- Start the application:
composer start
This command will copy the .env.example
file to .env
and start the PHP built-in server.
- Open your browser and navigate to http://localhost:8888.
You can log in with the following credentials:
Email: john.doe@gmail.com
Password: 123456
To stop the Docker containers, run:
docker-compose down -v --rmi all
This will stop the containers, remove the volumes, and delete the images.
Made with 🧡 by @jvzaniolo