jaishirb / technical-test-iw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

technical test Laravel 6.0

This repository contains the code for solving the technical test at Ideaware, also some cases of use of the framework's features like:

Beside Laravel, this project uses other tools like:

Installation

Development environment requirements :

Setting up your development environment on your local machine :

$ git clone https://github.com/guillaumebriday/laravel-blog.git
$ cd laravel-blog
$ sudo chmod u+x ./build.sh
$ ./build.sh

Now you can access the application via http://localhost:8000.

There is no need to run php artisan serve. PHP is already running in a dedicated container.

This will create a new user that you can use to sign in :

email: admin@admin.com
password: admin

Useful commands

Seeding the database :

$ docker-compose run --rm blog-server php artisan db:seed

Running tests :

$ docker-compose run --rm blog-server ./vendor/bin/phpunit --cache-result --order-by=defects --stop-on-defect

Running php-cs-fixer :

$ docker-compose run --rm --no-deps blog-server ./vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --dry-run --diff

Generating backup :

$ docker-compose run --rm blog-server php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
$ docker-compose run --rm blog-server php artisan backup:run

Generating fake data :

$ docker-compose run --rm blog-server php artisan db:seed --class=DevDatabaseSeeder

Discover package

$ docker-compose run --rm --no-deps blog-server php artisan package:discover

In development environnement, rebuild the database :

$ docker-compose run --rm blog-server php artisan migrate:fresh --seed

Accessing the API

You can access to the REST API. API requests require authentication via token. You can create a new token in your user profile.

Then, you can use this token either as url parameter or in Authorization header :

# Url parameter
GET http://laravel-blog.app/api/v1/posts?api_token=your_private_token_here

# Authorization Header
curl --header "Authorization: Bearer your_private_token_here" http://laravel-blog.app/api/v1/posts

API are prefixed by api and the API version number like so v1.

Do not forget to set the X-Requested-With header to XMLHttpRequest. Otherwise, Laravel won't recognize the call as an AJAX request.

To list all the available routes for API :

$ docker-compose run --rm --no-deps blog-server php artisan route:list --path=api

About


Languages

Language:PHP 79.9%Language:HTML 17.0%Language:Vue 1.9%Language:JavaScript 0.6%Language:Dockerfile 0.3%Language:Shell 0.3%