This web application uses GIPHY Public API to search within all GIFs they made available.
All commands below should be executed in cli mode, inside application directory.
You should have PHP >= 7.2.4
, mysql
, composer
and npm
installed on your system, so you can execute below commands.
You can use php artisan
commands with this Lumen project.
You should have empty mysql database ready to use with application.
- Run
composer install
to install required composer packages. - Rename
.env.example
to.env
and set some required values like:- Your mysql database information
DB_DATABASE
,DB_USERNAME
andDB_PASSWORD
,DB_HOST
andDB_PORT
if required. JWT_SECRET
random string required forjwt-auth
Package.RECAPTCHA_SECRET_KEY
andMIX_RECPATCHA_SITE_KEY
to enableGoogle reCaptcha v3
.GIPHY_API_KEY
to enable GIPHY API.
- Your mysql database information
- Run
php artisan migrate
to migrate all database migrations files. - Run
npm install
to install required npm dependencies. - Run
npm run dev
to compile Vue assets into public folder. - Run
php artisan serve
to start the application, it should be working onhttp://localhost:8000
and that's it.
-
Gitlab (default):
- This workflow used for private repository
- Add the following variables to your repository:
ACCESS_TOKEN
created with api scopeCONTAINER_REGISTRY
registry.gitlab.com/OWNER/REPOSITORYDOCKER_COMPOSE_URL
https://gitlab.com/api/v4/projects/PROJECT_ID/repository/files/docker-compose.yml/raw?ref=masterSSH_PRIVATE_KEY
SSH_SERVER_ADDRESS
SSH_SERVER_USERNAME
- You can trigger this workflow manually.
-
Github:
- This workflow used for public repository
- Enable local and third party Actions for your repository
- Add the following secrets to your repository:
CONTAINER_REGISTRY
docker.pkg.github.com/OWNER/REPOSITORYDOCKER_COMPOSE_URL
https://raw.githubusercontent.com/OWNER/REPOSITORY/master/docker-compose.ymlSSH_PRIVATE_KEY
SSH_SERVER_ADDRESS
SSH_SERVER_USERNAME
- Edit
services.web.image
indocker-compose.yml
to docker.pkg.github.com/OWNER/REPOSITORY/web:latest- docker pull from public github packages requires authentication
- You can trigger this workflow by star your project.
After first time deployment, execute this command on your server to migrate all database migrations files
docker exec gif-flip_web_1 php artisan migrate --force
- Authentication System (Register with reCaptcha, Login, Logout).
- Search GIFs using GIPHY API, (Authentication not required).
- Results displayed in a Grid of Thumbnails Layout
- Fully animated GIF can be viewed in a LightBox Slideshow with navigation controls, Favorite Button and Copy Shorten-URL Button.
- Authenticated Users can List their Search History.
- Authenticated Users can Favorite their Beloved GIFs, and List All of Them.
\app\Http\Controllers\AuthController.php
register: store a new user (username, email and password), after reCaptcha test against bot scripting.
login: Login user and return JWT token.
me: Get authenticated user object.
logout: Logout user
refresh: Refresh JWT token for another 1 hour.
respondWithToken: Return JWT token with its expiry in seconds.
\app\Http\Controllers\GifController.php
search: Search for GIFs via GIPHY API (query_string and offset) , save URLs of every GIF in database and encoded them, save a row in search history if there is an authenticated user.
decodeURL: Decode Shorten URL, get basic URL information from database and redirect user to it.
history: Return Search History for authenticated user.
favorite: Favorite GIF by authenticated user.
unfavorite: Unfavorite GIF by authenticated user.
\app\ShortURL.php
encode: Encode URL ID via base62 algorithm, and return encoded string.
- URL goes into dedicated database table.
- Its unique id (integer, auto-increment start from 1000) encoded and sent with search results to SPA.
- All shortend URLs pass specific route
/g/{url}
whereurl
is string to decode. - The system will fetch URL information from database, and redirect user to it.