Welcome to Aramis Rest API
What's inside ?
A REST API developed using Symfony 3.1 , FosRestBundle and JMSSerializerBundle.
The purpose is to handle a basic list of cars., (*1)
Installation
Make sure MySQL and PHP >=5.5.9 are installed., (*2)
-
Choose your favorite way to get composer., (*3)
-
Install project :, (*4)
php composer.phar create-project emmanuel-ba/aramis aramis -sdev
, (*5)
database credentials should be asked during installation, (*6)
-
Create database:, (*7)
cd aramis, (*8)
php bin/console doctrine:database:create, (*9)
php bin/console doctrine:schema:update --force, (*10)
you can alternatively use the mysql dump file provided (aramis.sql)., (*11)
-
Load fixtures :, (*12)
php bin/console doctrine:fixtures:load
, (*13)
-
Launch tests with phpunit:, (*14)
phpunit
, (*15)
-
Start PHP's built-in web server using Symfony Command :, (*16)
php bin/console server:run
, (*17)
Api should be available at http:localhost:8000, (*18)
Test API
Quick tests using Postman
You need to have postman installed. Have a look at the Chrome extension, (*19)
- Load the provided environment and collection in postman :
- environment : Aramis.postman_collection.json
- collection : TEST.postman_environment.json
Run the tests on the collection, (*20)
There should be 22 tests passed, (*21)
Manual tests using curl
- GET cars (response code 200 expected)
>
curl -X GET -H "Cache-Control: no-cache" "http://localhost:8000/cars", (*22)
- GET car (response code 200 expected)
>
curl -X GET -H "Cache-Control: no-cache" "http://localhost:8000/car/1", (*23)
- POST car (response code 201 expected)
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"maker" : "Seat",
"model" : "Leon",
"price" : 15000,
"option" : [{"name" : "Spoiler"}, {"name" : "GPS"}],
"equipment" : [{"name" : "ABS"}, {"name" : "Turbo"}]
}
}' "http://localhost:8000/car", (*24)
- INVALID POST car (response code 400 expected)
>
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"price" : 15000,
"option" : [{"name" : "Spoiler"}, {"name" : "GPS"}],
"equipment" : [{"name" : "ABS"}, {"name" : "Turbo"}]
}
}' "http://localhost:8000/car", (*25)
- PUT car (response code 204 expected)
>
curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"maker" : "Audi",
"model" : "Q7",
"price" : 75000,
"option" : [{"name" : "Camera recul"}, {"name" : "Pack cuir"}],
"equipment" : [{"name" : "Boite auto"}, {"name" : "Climatisation"}]
}
}' "http://localhost:8000/car/3", (*26)
- INVALID put car (response code 400 expected)
>
curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"maker" : "Audi",
"model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"price" : 75000,
"option" : [{"name" : "Camera recul"}, {"name" : "Pack cuir"}],
"equipment" : [{"name" : "Boite auto"}, {"name" : "Climatisation"}]
}
}' "http://localhost:8000/car/3", (*27)
- PATCH car (response code 204 expected)
>
curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"model" : "Q5"
}
}' "http://localhost:8000/car/3", (*28)
INVALID PATCH : (response code 400 expected), (*29)
>
curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" :
{
"model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"
}
}' "http://localhost:8000/car/3", (*30)
DELETE a car : (response code 204 expected), (*31)
curl -X DELETE -H "Cache-Control: no-cache" "http://localhost:8000/car/3", (*32)