This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

Overview

PHP API TO-DO-LIST v.2.0

This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses and the like. For this reason, it has few EndPoints (resources) to use, and can be expanded according to the need.

As it is an instructional project, it is not recommended that it be applied in a production environment, as safety routines and tests have not been implemented. These resources must be researched and implemented, following the current rules, in addition to good practices. Built in PHP 7 (see below), it allows the beginner to understand the mechanisms of access to the resources of an API.

PHP 7.4.3 (cli) (built: Jul  5 2021 15:13:35) ( NTS )
Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

How to use this content?

This content has free license for use (CC BY-SA 4.0).

If you want collaborate in this repository with any improvements you have made. To do this, just make a Fork and send Pull Requests.

Composer

Changes should be updated via composer dump-autoload -o on your local machine.

TODO

  • Fixed token auth in update mode
  • Fixed system login
  • Update username and password
  • Create log auth method

Documentation

This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

API Structure

+---api
    \task\
        ---delete
        ---edit
        ---new
        ---search
        ---update
    \user\
        ---new
        ---search
        ---update
+---src
    \---Database
    \---Helpers
    \---Task
    \---User
\---vendor
    \---composer

Database

The development uses the MySQL 5, which can be changed at any time according to the need for use. The database should be configured in Database\Database.php

Scripts SQL

CREATE DATABASE <name>;
CREATE TABLE users (
    id          INT(3) 	    NOT NULL PRIMARY KEY AUTO_INCREMENT,
    name        VARCHAR(50) NOT NULL,
    email       VARCHAR(50) NOT NULL,
    username    VARCHAR(20) NOT NULL,
    password    VARCHAR(20) NOT NULL,
    token       VARCHAR(20) NOT NULL
);
CREATE TABLE tasks (
    id          INT(3) 	    NOT NULL PRIMARY KEY AUTO_INCREMENT,
    userId      INT(3)      NOT NULL,    
    name        VARCHAR(50) NOT NULL,
    date        date        NOT NULL,
    realized    INT(1)      NOT NULL
);

Token

To use this API, a user must first be created with resource below.

A TOKEN will be returned that should be used in all subsequent requests for both user and task data manipulation.

Resources (User)

Resource URI Method
NEW /api/user/new/ POST

url = 'http://URI/api/user/new/';

payload = {
    "name": "name",
    "email": "email",
    "username": "username",
    "password": "password"
}

header = {
    "content-type": "application/json"
}
Success (User created)
{
    "message": "User Successfully Added",
    "userid": "user_id",
    "token": "TOKEN value"
}
Warnings
{
  "message": "Invalid Arguments Number (Expected Four)"
}
{
  "message": "Could Not Add User"
}
{
  "message": "User Already Exists"
}

Resource URI Method
LOGIN /api/user/login/ POST
url = 'http://URI/api/user/login/';

payload = {
    "username": "username",
    "password": "password"
}

header = {
    "content-type": "application/json"
}
Success
{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "token": "YOUR_TOKEN"
}
Warnings
{
  "message": "Invalid Arguments Number (Expected Two)"
}
{
  "message": "Incorrect username and/or password"
}

Resource URI Method
UPDATE /api/user/update/ PUT

Attention: username and password can not be changed in this version.

url = 'http://URI/api/user/update/';

payload = {
    "name": "name",
    "email": "email",
    "username": "username",
    "password": "password"
}

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success
{
    "message": "User Successfully Updated'
}
Warnings
{
  "message": "Invalid Arguments Number (Expected Four)"
}
{
  "message": "Incorrect username and/or password"
}
{
  "message": "Could Not Update User"
}

Resources (Task)

Resource URI Method
NEW /api/task/new/ POST

url = 'http://URI/api/task/new/';

payload = {
    "user_id": "user_id",
    "name": "Task name"
}

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success (Task created)
{
    "message": "Taks Successfully Added"
}
Warnings
{
  "message": "Invalid Arguments Number (Expected Two)"
}
{
  "message": "Could Not Add Task"
}
Resource URI Method
SEARCH /api/task/search/ POST

Payload is not necessary, as the control is performed by token.

Realized field accept values: "0" (open) and "1" (realized)

url = 'http://URI/api/task/search/';

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success
  [
      {
          "id": 1,
          "userId": 1,
          "name": "task name",
          "date": "2021-08-16",
          "realized": 0
      }
  ]
Resource URI Method
UPDATE /api/task/update/ PUT

url = 'http://URI/api/task/update/';

payload = {
    "id": "value",
    "name": "Task name",
    "realized": "value"
}

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success
{
    "message": "Task Successfully Updated"
}
Warnings
{
  "message": "Task(s) not found"
}
{
  "message": "Method Not Allowed"
}
{
  "message": "Invalid Arguments Number (Expected Three)"
}
Resource URI Method
EDIT /api/task/edit/ POST

url = 'http://URI/api/task/edit/';

payload = {
    "id": "value"
}

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success
[
  {
      "id": 2,
      "userId": 1,
      "name": "Task name",
      "date": "2021-08-16",
      "realized": 0
  }
]
Resource URI Method
DELETE /api/task/delete/ DELETE

url = 'http://URI/api/task/delete/';

payload = {
    "id": "id_task"
}

header = {
    "content-type": "application/json",
    "Authorization": "YOUR_TOKEN"
}
Success
{
    "message": "Task deleted Successfuly"
}
{
    "message": "Task not exist"
}

Other Warnings
{
  "message": "Bad Request (Invalid Syntax)"
}
{
  "message": "Token Refused"
}
{
  "message": "Invalid or Missing Token"
}
{
  "message": "Payload Precondition Failed"
}
{
  "message": "Method Not Allowed"
}
" } ">
{
  "message": "
   
    "
   
}
" } ">
{
  "message": "
   
    "
   
}

Try Online


How to cite this content

DE SOUZA, Edson Melo (2021, August 16). PHP API TO-DO-LIST v.2.0.
Available in: https://github.com/EdsonMSouza/php-api-to-do-list

Or BibTeX for LaTeX:

@misc{desouza2020phpapi,
  author = {DE SOUZA, Edson Melo},
  title = {PHP API TO-DO-LIST v.2.0},
  url = {https://github.com/EdsonMSouza/php-api-to-do-list},
  year = {2021},
  month = {August}
}

License

CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

You might also like...
A list of all the Belgian stations and their properties used within the iRail project

All stations in Belgium We try to maintain a list of all the stations in Belgium using CSV so everyone can help to maintain it on github. Furthermore,

A collective list of free APIs

Public APIs A collective list of free APIs for use in software and web development Status The Project Contributing Guide • API for this project • Issu

Berisikan tentang list alquran termasuk dengan terjemahan, tafsir dan murotalnya

Quran Cindy Quran Cindy adalah merupakan sebuah alquran berbasis web. Web application ini menggunakan bahasa pemrograman PHP dengan framework Laravel

A RESTful and extendable Backend as a Service that provides instant backend to develop sites and apps faster, with dead-simple integration for JavaScript, iOS, Android and more.

Welcome to hook ![Gitter](https://badges.gitter.im/Join Chat.svg) hook is a RESTful, extendable Backend as a Service that provides instant backend to

The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login

Facebook SDK for PHP (v5) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

PHP & MySQL Based Simple Application
PHP & MySQL Based Simple Application

Al Quran Technology Pages localhost/index.php Single Surah Page localhost/pages/single.php?no=1&name=আল%20ফাতিহা&ty=7 Data Source MySQL Database Local

A Statamic Pro addon that provides alternative GraphQL queries for collections, entries and global sets.

Statamic Enhanced GraphQL A Statamic CMS GraphQL Addon that provides alternative GraphQL queries for collections, entries and global sets. ⚠️ This is

Comments
  • General minors and majors corrections

    General minors and majors corrections

    Minors

    • Correction in README to improve visualization of resources
    • Correction codes formatting (all sources)
    • Documentation to all methods

    Majors

    • Add of MD5 for user and password fields
    • Fixed EndPoint variable returns
    • Removed redundant variables
    • Correction in size fields (username and password) to suit MD5
    opened by EdsonMSouza 0
  • Standardization of documentation and request return

    Standardization of documentation and request return

    • api/user/new/index.php Line 70 - The "userid" value has been changed to "id" to keep the naming pattern;

    • README #Resources (User) Line 124 - The key name "userid" has been changed to "id" to keep the naming pattern; Line 397 - The list of warnings has been inserted to maintain the documentation standard;

    • src/User/UserModel.php Line 126 - Convert created userid from string to int to keep the return pattern;

    opened by arthur-timoteo 0
Owner
Edson M. de Souza
Professor & Researcher at Information Technology
Edson M. de Souza
Best resources restful api for developers (with JSON:API standar specification design)

List API Best resources restful api for developers (with JSON:API standar specification design). API Resource Endpoint Name Resource Description Al Qu

Noval 2 Jan 18, 2022
A small library that provides functionality to PHP 8.1 enums to act as BitMask flags

PHP Enum BitMask A small library that provides functionality to PHP 8.1 enums to act as BitMask flags. Why? Sometimes you need some flags on the objec

FramJet 53 Dec 11, 2022
pedre-response is a standard structure of json response

PedreResponse It's very important to use same structure for responses in large projects that PedreResponse package can do it for you. PedreResponse is

Pedram Rezaei 2 Dec 22, 2021
A Restfull backend api for tasks managment

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Kpanou Gilles 3 Aug 2, 2021
JSON:API serializer for PHP resources

kwai-jsonapi A JSON:API serializer for PHP classes using PHP attributes. Currently, this library has no support for links. Installation composer requi

Franky Braem 1 Jan 19, 2022
Best resources restful api for developers

Best resources restful api for developers (with JSON:API standar specification design).

Noval 2 Jan 18, 2022
The API for my blog series about creating a simple stock portfolio

Stockportfolio API This repository is the API part of my blog series 'How to create a simple application using Symfony and React Native' which can be

Wouter Carabain 4 Sep 5, 2022
A Symfony bundle that provides #StandWithUkraine banner and has some built-in features to block access to your resource for Russian-speaking users.

StandWithUkraineBundle На русском? Смотри README.ru.md This bundle provides a built-in StandWithUkraine banner for your Symfony application and has so

Victor Bocharsky 10 Nov 12, 2022
System to control your app from site

ProgramManager System to control your app from site You can add more featutre and develop page you must use DataBase mysql 3 columns , 1 for id ( AI c

OmarMazin 4 Mar 17, 2022
The news bundle adds news functionality to Contao 4

Contao 4 news bundle The news bundle adds news functionality to Contao 4. Contao is an Open Source PHP Content Management System for people who want a

Contao 8 Jan 10, 2022