This project sets up a web service providing a read-only list of users.
It allows you to provide user data as different file format. As to now, it only support JSON and CSV files. Two sample files are provided as a first set of usable data.
See Provide your data to see how to provide your own data.
See API for the web service specification.
Note: This repository is a test case for OAT dev team and should only be seen as a development process log. See Development notes to see the development details.
- PHP 7.1+
- Symfony 4.2+
- Apache or any other web server
Since this is not in the packagist repositories (for obvious reasons), the installation process just follows these steps :
-
Clone this repo (git clone https://github.com/julix/oat-test.git) or download and unzip the archive to the directory of your choice on your server (e.g. /var/www/oat-test).
-
Run the following command in the install directory to install all the necessary packages:
$ composer update
-
Set up your vhost document root to the /public directory of the repository (e.g. /var/www/oat-test/public). See Apache vhost examples or NginX vhost examples for more information.
-
Try and visit the service page in your web browser: /index.php/users. You should see a rather large Json string.
To provide your own data:
- Put your JSON or CSV file in the /_resources directory
- Reference it in the corresponding attribute in the /config/services.yaml:
- json_source_file for JSON file (line 7)
- csv_source_file for CSV file (line 8)
- In the same file, choose the corresponding data provider (line 50):
- @app.json_provider for JSON file
- @app.csv_provider for CSV file
The JSON file must contain a array of objects, with the following fields :
The CSV file must contain a user by line, with the following fields :
- login
- password
- title
- lastname
- firstname
- gender
- picture
- address
Two endpoints are provided:
Verb | URI | Parameters | Type | Description |
---|---|---|---|---|
GET | /users | Returns the whole user list. | ||
limit | Integer (default: 0) | Limits the number of results returned (0 means no limit). | ||
offset | Integer (default: 0) | Index of the first result returned (beginning at 0). | ||
name | String | Returns all users responding to the given name (searches in first name, last name, e-mail and login). |
/users
Returns the whole user list.
/users/?limit=10
Returns users at indexes 1 to 10.
/users/?limit=10&offset=30
Returns users at indexes 31 to 40.
/users/?name=doe
Returns all users having the string "doe" in their first name, last name, e-mail or login.
Verb | URI | Description |
---|---|---|
GET | /users/{id} | Returns the user with the given id or an error 404 when 0 or more than 1 user is found. |
/users/{johndoe}
Returns the user "johndoe" details.