Skip to content

jahidulpabelislam/portfolio-api

Repository files navigation

Portfolio API

CodeFactor Codacy Badge

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.

Requirements

  • Git
  • PHP 8.0+
  • PHP PDO
  • Composer
  • MySQL 5+
  • Apache

Setup

  1. Clone repo with git@github.com:jahidulpabelislam/portfolio-api.git.

  2. Navigate to project folder and run composer install.

  3. Create new database.

  4. A MySQL user with select, insert, update & delete capabilities on the new database.

  5. Import /set-up/base-structure.sql into the newly created database.

  6. Run migrations from /migrations/* (if any) into MySQL in the order of the number at the start of the filenames.

  7. 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.

API

Endpoints

Resources

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

Auth

URI Description GET POST PUT DELETE
/auth/login/ Log in
/auth/logout/ Log out
/auth/status/ Get current auth status