This API is to manage the projects and their images displayed in my Portfolio. This is all connected together via the CMS Repo as well the actual Portfolio Repo.
This (and the CMS) was created as I had realised that all my projects were consistent regarding what information was being shown. Therefore, for future-proofing and better maintainability, I thought it would be good to enforce a project structure, so each project has the same information. This was done by adding CRUD abilities through a database, this API and CMS. By doing this, on the website, I can use templating to generate the projects area, this reduced the duplication of HTML. I can then also easily update a project structure for all current projects at once (e.g. adding a new piece of information). I will only need to update the database structure, API endpoints, CMS, and website.
The first two versions were developed within the Portfolio repo. However, from v3, it was decided it would be a good idea to separate the API (and the CMS) from the portfolio to aid maintainability and readability.
- Git
- PHP 8.0+
- PHP PDO
- Composer
- MySQL 5+
- Apache
-
Clone repo with
git@github.com:jahidulpabelislam/portfolio-api.git
. -
Navigate to project folder and run
composer install
. -
Create new database.
-
A MySQL user with select, insert, update & delete capabilities on the new database.
-
Import
/set-up/base-structure.sql
into the newly created database. -
Run migrations from
/migrations/*
(if any) into MySQL in the order of the number at the start of the filenames. -
Copy and fill in example files (in any order).
- Copy
/set-up/Manager-sample.php
and move to/src/Auth/Manager.php
then update all 3 functions with your auth functionality.
- Copy
URI | Description | GET |
POST |
PUT |
DELETE |
---|---|---|---|---|---|
/projects/ | All projects | ✔ | ✔ | ✖ | ✖ |
/projects/{projectId}/ | A single project | ✔ | ✖ | ✔ | ✔ |
/projects/{projectId}/images/ | Images attached to a single project | ✔ | ✔ | ✖ | ✖ |
/projects/{projectId}/images/{imageId}/ | A single image attached to a single project | ✔ | ✖ | ✖ | ✔ |
URI | Description | GET |
POST |
PUT |
DELETE |
---|---|---|---|---|---|
/auth/login/ | Log in | ✖ | ✔ | ✖ | ✖ |
/auth/logout/ | Log out | ✖ | ✖ | ✖ | ✔ |
/auth/status/ | Get current auth status | ✔ | ✖ | ✖ | ✖ |