PHP HTML Ruby Vue JavaScript
Switch branches/tags
Clone or download
Permalink
Failed to load latest commit information.
app Formating validations Jul 3, 2018
bootstrap Updating files for Laravel 5.5 Sep 5, 2017
config Adding an Horizon service Provider May 11, 2018
database Fixing seeders for User with bcrypt Jul 3, 2018
lib/capistrano/tasks Adding capistrano tasks Nov 9, 2017
provisioning Adding Horizon in Docker container May 11, 2018
public Adding media views in admin Apr 14, 2018
resources Formating validations Jul 3, 2018
routes Adding a controller to manage media over API Apr 14, 2018
storage Initial commit Dec 18, 2016
tests Removing setPasswordAttribute of User to prevent error on ResetPassword Jun 7, 2018
.env.example Setting up Redis as default broadcaster and queue driver May 11, 2018
.env.testing Updating .env.testing to add DB_PORT example configuration May 11, 2018
.env.travis Adding travis config files Apr 11, 2017
.gitattributes Initial commit Dec 18, 2016
.gitignore Adding the config file for medialibrary Apr 14, 2018
.php_cs Updating php-cs config Nov 20, 2017
.travis.yml Adding an addon for travis CI to enabled mysql 5.7 Apr 20, 2018
Capfile Running cap install command Nov 4, 2017
Gemfile Adding capistrano as gem dependencies Nov 4, 2017
Gemfile.lock Adding capistrano as gem dependencies Nov 4, 2017
LICENSE License for 2018 Feb 8, 2018
artisan Updating files for Laravel 5.5 Sep 5, 2017
composer.json Adding Laravel/Horizon May 11, 2018
composer.lock Adding Laravel/Horizon May 11, 2018
docker-compose.yml Adding Horizon in Docker container May 11, 2018
laravel-echo-server.json Adding the laravel-echo-server config file Nov 11, 2017
package-lock.json Adding media views in admin Apr 14, 2018
package.json Adding media views in admin Apr 14, 2018
phpunit.xml Adding browser tests in phpunit config Nov 29, 2017
readme.md Adding the minimal docker version required Jul 5, 2018
server.php Initial commit Dec 18, 2016
webpack.mix.js Versionning assets only in production Apr 30, 2018

readme.md

Laravel 5.6 blog

Build Status Donate

The purpose of this repository is to show good development practices on Laravel as well as to present cases of use of the framework's functionalities like :

Beside Laravel, this project uses other tools like :

Some screenshots

You can find some screenshots of the application on : https://imgur.com/a/Jbnwj

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
$ cp .env.example .env
$ docker-compose run --rm --no-deps blog-server composer install
$ docker-compose run --rm --no-deps blog-server php artisan key:generate
$ docker-compose run --rm --no-deps blog-server php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider"
$ docker-compose run --rm --no-deps blog-server php artisan storage:link
$ docker run --rm -it -v $(pwd):/app -w /app node npm install
$ docker-compose up -d

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.

Before starting

You need to run the migrations with the seeds :

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

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

Email : darthvader@deathstar.ds
Password : 4nak1n

And then, compile the assets :

$ docker run --rm -it -v $(pwd):/app -w /app node npm run dev

Starting job for newsletter :

$ docker-compose run blog-server php artisan tinker
> PrepareNewsletterSubscriptionEmail::dispatch();

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 --stop-on-failure

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 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

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

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

More details

More details are available or to come on Guillaume Briday's blog (French).

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

License

This project is released under the MIT license.