The purpose of this repository is to check skills of candidates applying to Orba for a position of PHP Developer. If you are here, you probably want to work with us :-).
Random Cat Browser is a simple application built using Symfony Microkernel. The only feature of the application is showing random photo of a cat. In current state it shows only one hardcoded photo. Your task will be to unhardcode photo getter by applying connection to Random Cat API.
It's a simple JSON API with only one endpoint: http://randomcatapi.orbalab.com/
It is protected by API key. To be authorized you must pass api_key
GET parameter to the endpoint. The key that you may use is 5up3rc0nf1d3n714llp455w0rdf0rc47s
.
As a response for request to this API you will get simple JSON object with just one attribute called "url", eg. {"url": "http://supercats.com/randomkitty123.jpg"}
.
The API is heavily loaded, so from time to time (approximately 25% of all requests) it will not respond with HTTP status 200.
Collection of cats photos used by the API is a little bit outdated, so from time to time (approximately 30% of successfull requests) it will return URL pointing to a 404 page.
- Fork this repository.
- Install application locally.
- Apply connection to Random Cat API in
\App\Service\RandomCatUrlGetter::getUrl
method. - Frontend should always show correct image. In case of any problems with API, internal
public/images/404.jpg
photo must be shown. - Log all failed API responses and invalid images to a text log file.
- Write unit tests to get more points.
- Make your code SOLID to get even more points.
- When you're done, create a Pull Request with your changes.
You can install application on your local environment or using Docker.
You need to have Docker and Docker-Compose installed on your local machine.
- Clone your forked repository (master branch) locally.
- CD to project root and run
docker-compose up
. - Application will be accessible by the following address:
http://localhost:8000/
. - Unit tests can be executed by running the following command:
docker exec -i -t <CONTAINER_NAME> sh -c "/app/vendor/bin/simple-phpunit /app/src"
. - Composer can be executed by running the following command:
docker exec -i -t <CONTAINER_NAME> sh -c "cd /app && composer"
. <CONTAINER_NAME>
can be checked by running the following command:docker ps
. It will be something likeorbamrandomcats_php_1_ed01e2011bb6
.
You need to have PHP 7.1 and Composer installed on your local machine.
- Clone your forked repository (master branch) locally.
- CD to project root and run
composer install
. - Set-up PHP built-in server by running the following command:
php -S localhost:8000 -t public
. - Application will be accessible by the following address:
http://localhost:8000/
. - Unit tests can be executed by running the following command:
vendor/bin/simple-phpunit src
.