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 :
- Authentication
- API
- Token authentication
- Transformers
- Versioning
- Blade
- Cache
- Filesystem
- Helpers
- Jobs & Queues
- Localization
- Migrations
- Policies
- Providers
- Requests
- Seeding & Factories
- Testing
You can use Laravel homestead to setup your local development environment. On other environment, make sure the default requirements are available.
$ composer install
$ npm install
$ php artisan migrate
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 : [email protected]
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());
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 are available or to come on Guillaume Briday's blog (French).
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
This project is released under the MIT license.