A simple Lumen based lightweight task management application with simple UI and API endpoint. Each task can have subtasks and tasks without subtasks have points. That means parent task has a sum of points from subtasks. What is more, if all subtasks of a task are done, then task also is done. If at least one subtask of a task marked as not done then it also becomes not done.
- The application is using PHP Lumen framework;
- The application have a simple UI and required API endpoints;
- It is follow PSR-2 style guide;
- The Application is written in OOP;
- The code in simple and clean;
- The code is tested in PHPUnit test.
First clone this repository by using git clone https://github.com/devawal/api.git
And run composer install
- PHP Unit is used for unit testing.
- PHP Coding Standards Fixer is usse for maintain
PSR-2coding standerd
The application is using MySQL database and use default connection settings. To connect and create table at first create a database with a name and configure it in .env file. In this application I used tasks_management.
Run the migration command by typing console command php artisan migrate:install it will create migration table then run php artisan migrate to install the migration in the database.
The application is using users from the following link
https://gitlab.iterato.lt/snippets/3/raw
The URL can be updated from App\Http\Controllers\TasksController in
/**
* The user data source URL.
*
* @var string
*/
protected $userSource = 'https://gitlab.iterato.lt/snippets/3/raw';
End point for create task is: http://your_host/api/task which accept HTTP POST request whth the following input parameters
{
"parent_id":null,
"user_id":1,
"title":"Task 1",
"points":5,
"is_done":1,
"email":"john.doe@email.com"
}
The application API will return 201 status code if it passed all validations otherwise it will throw 400 status code with validation message
{
"parent_id": null,
"user_id": 2,
"title": "Task 1",
"points": 5,
"is_done": 1,
"created_at": "2019-10-12 14:34:15",
"updated_at": "2019-10-12 14:34:15",
"id": 1
}
End point for update task is: http://your_host/api/task/{task_id} which accept HTTP PUT request with the following input parameters
{
"parent_id":null,
"user_id":2,
"title":"Task 1",
"points":10,
"is_done":1,
"email":"john.doe@email.com"
}
The application API will return 201 status code if it passed all validations otherwise it will throw 400 status code with validation message
All other internal errors will return 500 with error message
End point for all task: http://your_host/tasks
The application is tested with random data set using faker. For Unit test following is the command ./vendor/bin/phpunit
Test class tests\TasksTest
Test configuration file phpunit.xml
$ ./vendor/bin/phpunit
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 1.83 seconds, Memory: 10.00MB
OK (2 tests, 2 assertions)