This repository contains a scaffold of a Laravel Project, with 1 Model called Url
.
Your goal is to create an API end-point which allows for creating new Urls and provide a shortening service for them.
- Implement query & mutation in GraphQL for Url model – allowing for create, read and delete of urls.
- If no
slug
have been given one is auto generated. - Cover
slug
generation with a unit test. - On route
/s/<slug>
we should be redirected to corresponding url.
Please feel free to use any development environment which is most convenient to you.
PHP ^7.4
MySQL or any compatible server
We have included a DDEV (See Useful resources for more info about DDEV) based configuration for the project to get up and running very quickly – if you already have another local development setup jump to next section.
ddev start && ddev install
The first commands (ddev start
) boots up the docker containers and adds them to the local routing layer – the second command is a prebundle set of commands that run all commands listed in the next section.
If you do it your self you will need to run - assuming you have configured your .env file with credentials for MySQL
cp .env.example .env
mkdir -p storage/framework/sessions storage/framework/views storage/framework/cache
Make sure to adjust your .env file to match your local environments configurations.
composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
This is a standard Laravel project, with a minimal configuration/changes done to it – you will find the normal User model which can be ignored as we have no expectations that the above require any kind of authentication.
The Url
model have been added to handle model based actions hint great place to handle the auto-generation of slug.
For testing slug generation you can use
ddev artisan db:wipe && ddev artisan db:seed
# Or alternative if you are using your own flavor of local environment.
php artisan db:wipe && php artisan db:seed
- Lighthouse GraphQL package for Laravel
- DDEV - Local docker based PHP Development environment