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
- Homestead
- Jobs & Queues
- Localization
- Migrations
- Policies
- Providers
- Requests
- Seeding & Factories
- Testing
Development environment requirements :
Setting up your development environment on your local machine with Homestead :
$ git clone https://github.com/guillaumebriday/laravel-blog.git
$ cd laravel-blog
$ cp .env.dev .env
$ composer install
$ vagrant up
Now you can access the site via http://192.168.10.10 or http://laravel-blog.app if you added the domain to your hosts file.
The following commands must be executed on the virtual machine :
$ vagrant ssh
$ cd /home/vagrant/laravel-blog
You need to run the migrations :
$ php artisan migrate
Seed the database :
$ php artisan db:seed
This will create a new user that you can use to sign in :
Email : [email protected]
Password : 4nak1n
And then, compile the assets :
$ npm install
$ npm run dev
The following commands must be executed on the virtual machine in the folder /home/vagrant/laravel-blog
.
Running tests :
$ ./vendor/bin/phpunit
Running php-cs-fixer :
$ ./vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --dry-run --diff
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.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
.
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.