Web Applications



  • ORM
  • CMS application

This is a DIY practical; there is no offline or online session.
Should you have any questions, please let me know.

You must implement and submit the assignment before 15.3.2024 23:59 UTC.

Assignment: Simple CMS


CMS stands for Content Management System. Your objective is to implement part of a simple CMS using Slim and Doctrine. Your solution must implement API to view an article's details, create an article, and list all articles. You must use only PHP. No JavaScript is allowed.

The article detail page is available at "./api/v1/article-detail/{identifier}". Where "{identifier}" is the article's identifier. It returns information about the article in JSON format. An example of the response is on a separate slide. If the article does not exist return 404.

The article list page is available at "./api/v1/articles". It returns information about the article in JSON format. An example of the response is on a separate slide. A user can employ the URL query attribute "author" to specify the name of an author as a filter. In such a case, only articles from the given author are returned.

The user can create an article using POST with JSON content at "./api/v1/articles". An example of the request is on a separate slide.

Database schema definition

Your database schema must resemble the one below. Feel free to add indices and foreign keys at will.

CREATE TABLE `Articles` (
  `author_id` int,
  `title` varchar(128) NOT NULL,
  `content` varchar(1024) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

CREATE TABLE `Authors` (
  `name` varchar(128) NOT NULL,
  PRIMARY KEY (`id`), 
  UNIQUE `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Note that "name" is unique in the table "Authors". Meaning there is only one author of the given name.

Remember that you can use phpMyAdmin to interact with the database.

Do not commit your login and password into the GitLab!

Article list response

  "articles": [
    { "identifier": "0", "title": "Using ORM in PHP" },
    { "identifier": "1", "title": "Using Slim in PHP" }

Empty article list response:

  "articles": [ ]

Article detail response

  "identifier": "0",
  "author": {
    "identifier": "0",
    "name": "Ailish"
  "title": "Using ORM in PHP",
  "content": ""

Article create request and response


  "author": "Ailish",
  "title": "Using ORM in PHP",
  "content": ""


  "identifier": "2"

Upon receiving the request, your program must check that the author with the given name exists. If the author does not exist, your program must create a new database record for the author. Then you program insert the article into the database. In the last step, your program returns JSON with the identifier of the newly created article.


The resources below may help you with the assignment from this lecture. Try to not read all of them, instead focus on the fast implementation of a functional solution. You can find information about Doctrine in the Getting Started with Doctrine guide.

Questions, ideas, or any other feedback?

Please feel free to use the anonymous feedback form.