This is a movie app written in Laravel.
- Clone the repo.
- Run
cp .env.example .env
- Run
php artisan key:generate
- Make sure the values in
.env
for database connection are correct. - Run
php artisan migrate --seed
// this will create the database and few records
If you do not have docker installed in your system. Refer here
There is docker compose file provided in the repo which has all the necessary steps to build and run a docker container to host the app.
You can access the site at http://localhost
or you can create a virtual host to point to 127.0.0.1
and access as a domain
The docker-compose also has a mysql server with credentials. You can use these credentials in your .env
file to connect to the database.
DB_CONNECTION=mysql
DB_HOST=mysql5.7
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
- Clone the repo.
- Run
docker-compose up
form the root of the project. - Run
docker exec -i mauqah php artisan key:generate
- Make sure the values in the
.env
are as mentioned above. - Run
docker exec -i mauqah php artisan migrate --seed
- You can browse the application at
http://localhost
This project uses PHP CS-Fixer to format the code and comply with PSR-2. To run this on pre-commit
hook.
Run ./hook.sh
to copy the file from hooks/pre-commit
to .git/hooks/pre-commit
/
redirects to/films
- See a list of movies at
/films
- Click the
Detail
button to see the detail of the movie - Navigate the pagination links
- Click the
- Click the detail
Go To Listing
button to go back to listing. - Go to
/films/#/films/create
to create a film.
This project tries to be framework agnostic in it's core business logic. All the code for the app is written inside src/
folder.
I have separated the module Films
to house all the logic for films
Controllers are inside Films\Actions
. I make use of Single Action Controllers.
This projects uses Repository Pattern
to separate database logic from the actual Entity
of the project.
Eloquent Models and Lower implementation of entities are not exposed anywhere outside of the Entities
of the project. All of the entities have their own Interfaces
so that they can be swapped later if need be.
All of the entities have their own Tranformers
as well. Transformers are used to filter out or add the parts of the api we want to expose. It creates a layer between Entity and Api which makes manipulating Entity output for an API very easy.
I have created my own implementation of Paginator
to separate Eloquent from the api. The ApiResponse
combines the Entities
, Transformera
and Paginator
to create appropriate response.
I have also created a Service
folder to house my services. This can be assumed as a Command
in a typical CommandBus
pattern. This holds all the data necessary to do the intended action. This object is immutable.
I like my objects to be immutable. Once created they do not change state. There are no setters in my classes.
The frontend of the application is written in VueJs.
I have added unit tests and feature tests for the application. Feature tests use sqlite
driver for database connection.
You can run tests by running ./vendor/bin/phpunit
from the root of the project
There is a github action that run the test on every push to the repo.