/laravel-blog

Laravel 5.4 blog example project with good practices

Primary LanguagePHPMIT LicenseMIT

build status

Laravel 5.4 blog

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 :

Installation

You can use Laravel homestead to setup your local development environment. On other environment, make sure the default requirements are available.

Before starting

$ composer install
$ npm install
$ php artisan migrate

Useful commands

Running tests :

$ ./vendor/bin/phpunit

Running php-cs-fixer :

$ ./vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --dry-run --diff

Compiling assets :

$ npm run dev

Running seeders :

$ php artisan db:seed

This will create a new user that you can use to sign in. Email : darthvader@deathstar.ds Password : 4nak1n

Generating fake data :

$ php artisan db:seed --class=DevDatabaseSeeder

Running the queue worker :

$ php artisan queue:work

Starting job for newsletter :

$ php artisan tinker
> dispatch(new App\Jobs\PrepareNewsletterSubscriptionEmail());

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.dev/api/v1/posts?api_token=your_private_token_here

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

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

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.