- This exposes a user model. A user has (at least) the following attributes:
- id - a unique user id
- email - a user's email address
- givenName - in the UK this is the user's first name
- familyName - in the UK this is the user's last name
- created - the date and time the user was added
- Have the ability to persist user information for at least the lifetime of the test.
- Expose functionality to create, read, update and delete (CRUD) users.
- Easily consumable by a plain HTTP client (e.g. cURL or Postman) or, if using a transport other than HTTP, be trivial to write a client application to consume it.
- Laravel
- PhP 7
- Composer
- Mysql
-
Clone the repo
git clone https://github.com/shorif2000/api
-
Install packages
composer update
-
Update
env
file with your mysql settingscp .env.example .env
-
Run migrations
php artisan migrate
-
Load some data
php artisan db:seed
-
Create api keys
php artisan passport:install
-
Run service locally
php artisan serve
curl -X POST http://localhost:8000/api/register \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"givenName": "Sharif", "familyName":"Uddin","email": "sharif.uddin@gmail.com", "password": "123", "password_confirmation": "123"}'
curl -X POST http://localhiiiiost:8000/api/login \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"email": "sharif.uddin@gmail.com", "password": "123"}'
Response
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiYWQ5YjU4MTU1NDgwNTZhM2E5MDZmYjU1OWRlNTdhMTZjZDhmYmVjMWJjYjFlNWEwNDllN2E0YzgyMGUwN2I4NDFmYmQxNDZhNjdjYjEzYTAiLCJpYXQiOiIxNjE1MTQ2NDEyLjA3NTU5NCIsIm5iZiI6IjE2MTUxNDY0MTIuMDc1NTk4IiwiZXhwIjoiMTYzMTA0NDAxMS45MTc0NjkiLCJzdWIiOiIxMSIsInNjb3BlcyI6W119.vNjyS95PqhpTHVd-nmRMcbw7kGnk-3PMIKTWwi9f0kFSeZhBGmZmc6JAtbIa8rpRu3P-26ZpbIzvUq1XVbI3DFu3qr2zvO2VamOJiHSzaCTP8ZChGK_j7mdCO6--NFt-aADc4GqywW_-N2Ztk_btSxs-PtqyLEPxYjxY9xoXlQcFYYH4S_9BMy4PfyVYxnezbcZNyBdHqoRPgpcEQgr2jFYqgcklZejng7uutSRiIj4EDLRwUu9AZfrFNa5vYbEgguX9ZonWJuFnxFJ8BQaoB1bEkCIUhhCheQvzo0U48kR2dQfTZ1zRN2wgb4gT3zvDrOWnzARObEWJBJ5UyEcNMyAxb3QME67lheT1faLM6CFO4S59iHksH7Dhon2LZ-rmiHzcVxc9Dxmwvk-6QCbyTSNcr2hbqu580vcbwOJOZo6YR_E3GE-9h0L7vWHsSG9BKsO9XnIaRlwQHcPG21wht88Uzw28PPLkzMs6mDsqAQ0ji8Ef1r95xTKLyhiY0dRRXdqqoh0Vp8n4ybictDSH5-7TuRM4NhKMmxcOp_wVAUWPHFiYOZY0RfIbZvfhNEPVHz_Ou1U1QPXF8RupfTRB4R8vOaJjzGBl05EFjLXvgyP1N5ybTJeSPbVLgZK2qWiwiZeuHjk3r66GruRNhwR35guE29m14TzK2_fgpP4gf4w",
"token_type": "Bearer"
}
This should return bearer token to use on all other requests
curl --location --request GET 'http://localhost:8000/api/users' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiYWQ5YjU4MTU1NDgwNTZhM2E5MDZmYjU1OWRlNTdhMTZjZDhmYmVjMWJjYjFlNWEwNDllN2E0YzgyMGUwN2I4NDFmYmQxNDZhNjdjYjEzYTAiLCJpYXQiOiIxNjE1MTQ2NDEyLjA3NTU5NCIsIm5iZiI6IjE2MTUxNDY0MTIuMDc1NTk4IiwiZXhwIjoiMTYzMTA0NDAxMS45MTc0NjkiLCJzdWIiOiIxMSIsInNjb3BlcyI6W119.vNjyS95PqhpTHVd-nmRMcbw7kGnk-3PMIKTWwi9f0kFSeZhBGmZmc6JAtbIa8rpRu3P-26ZpbIzvUq1XVbI3DFu3qr2zvO2VamOJiHSzaCTP8ZChGK_j7mdCO6--NFt-aADc4GqywW_-N2Ztk_btSxs-PtqyLEPxYjxY9xoXlQcFYYH4S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1JCWUNuRXFXNjZlcXdTUStCSU54ZzJxRmgiLCJtYWMiOiI4ZWM2YTgzMWFiNTQyZDQ0ODZhZGM1NTNhMTAzMzFiYzU4ZTQzNzA2Yzc3NWIwZjRmZTc1NjIwOWVhZDQxNTMyIn0%3D'
Should return array of users.
Run php artisan test tests/Feature
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Sharif Uddin