All artists
GEThttp://artists.test/api/v1/artists
=> all artists
Artists filter by active/inactive
GEThttp://artists.test/api/v1/artists?filter[inactive]
=> inactive
GEThttp://artists.test/api/v1/artists?filter[active]
=> active
Artists filter by email
GEThttp://artists.test/api/v1/artists?filter[email]=some_email
=> email
Error wrapped by Laravel's collection
GEThttp://artists.test/api/v1/artists?filter[ohmyerror]
=> error response with 400 HTTP code I didn't add any custom wrapper as Laravel has built-in if we use Collections.
API has Basic authorization, so pass Authorization: Basic development-pass
header in your requests.
Check tests/HTTP/artists.http
for request examples.
** You can replace artists.test
with localhost
if you host on 80 port. If port is different from 80, use localhost:<port>
.
All endpoints are paginated and wrapped as a Laravel collection, so the frontend part should use it without any issues.
If you use JetBrains production, such as PHPStorm, you can just right into ./tests/HTTP/artists.http
file to run HTTP requests right from the IDE (don't forget to select the dev environment located in ./tests/HTTP/http-client.env.json
).
Clone this repository:
git clone https://github.com/tlishchynskiy/artists-test
cd artists-test
And follow the instructions below:
If you have make
and docker
/podman
-compose installed:
** For immutable linux distros with pre-installed OCI containers, install podman-compose using rpm-ostree or similar.
make rollup
** Please don't forget about privileged ports and rootless setup, so it may throw an error if you are trying to build rootless compose without any configuration on your end.
** If make rollup
failed on database migration (db container is not booted at that moment), then type these commands manually:
make migrate
make seed
And you are good to do ;)
To enter the PHP container, run
make php
, then you are able to run compose/npm commands.
Otherwise, here are steps to rollup your local without make or docker/podman-compose
cp .env.example .env
composer install
php artisan key:generate
npm install && npm run dev
(optional)- Add database credentials to
.env
file php artisan migrate
php artisan db:seed
php artisan serve
If you want to add local domain to hosts file, you can run make
command or add it manually:
sudo make add-host
- Manually: add
127.0.0.1 artists.test
to/etc/hosts
file.
app/Http/Controllers/api/v1/ArtistsController.php
app/Http/Resources/ArtistCollection.php
database/factories/ArtistFactory.php
database/migrations/2024_02_05_132158_create_artists_table.php
database/seeders/ArtistsSeeder.php
routes/api/v1.php
tests/HTTP/artists.http
tests/HTTP/http-client.env.json