You will create a basic JSON API using PHP and SQL.
DO NOT use fully-fledged frameworks like Symfony or Laravel.
U can use libraries for routing, mailing etc.
-
Implement a login/logout to authorize for the API:
- Implement a route
/auth/loginwhich grants the client API access - Mandatory fields are
usernameandpassword - Implement a route
/auth/logoutwhich revokes the clients API access
- Implement a route
-
Implement a route accepting a
POSTrequest to/auth/loginwhich accepts ausernameandpasswordas input and authorizes the user for the API when credentials are valid. -
Implement the following models:
- Post
- id
- title
- author
- content
- dateCreated
- dateUpdated
- Author
- id
- firstName
- lastName
- dateCreated
- dateUpdated
- Post
-
Implement a persistence layer for
PostandAuthor -
Implement
GETroute for/postswhich returns all posts- Implement a pagination
- Implement a search by
title,contentandauthor - Implement optional order parameters
-
Implement a
POSTroute for/postswhich registers a new post- Mandatory fields are
title,author,content - Content can contain
HTML
- Mandatory fields are
-
Implement
GETroute for/authorwhich returns allAuthors- Implement a pagination
- Implement a search by
firstNameandlastName - Implement optional order parameters
-
Implement a
POSTroute for/authorwhich registers a newAuthor- Mandatory fields are
firstNameandlastName
- Mandatory fields are
Implement all changes following PHP best practices (PSR-1, PSR-2) and basic security principles.