In the future, this blog will be turned into a full-fledged open source blog site with an advanced admin panel, a more detailed React frontend interface and more enriched backend. I can't spare time right now because I'm busy with my fulltime work.
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 features like:
- Authentication
- API
- Sanctum
- API Resources
- Versioning
- Blade
- Broadcasting
- Cache
- Email Verification
- Filesystem
- Helpers
- Horizon
- Localization
- Migrations
- Policies
- Providers
- Requests
- Seeding & Factories
- Testing
- Homestead
Beside Laravel, this project uses other tools like:
- Bootstrap 5.x
- Pint
- Font Awesome
- Hotwired
- Redis
- spatie/laravel-medialibrary
- hotwired-laravel/turbo-laravel
- Many more to discover.
You can find some screenshots of the application on : https://imgur.com/a/Jbnwj
To create your development environment follow these instructions.
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
$ php artisan key:generate
$ php artisan horizon:install
$ php artisan telescope:install
$ php artisan storage:linkYou can use Mailpit to test your emails in development.
Once installed, open http://localhost:8025.
You need to run the migrations with the seeds :
$ php artisan migrate --seedThis will create a new user that you can use to sign in :
email: [email protected]
password: 4nak1nAnd then, compile the assets :
$ yarn dev # or yarn watchStarting job for newsletter :
$ php artisan tinker
> PrepareNewsletterSubscriptionEmail::dispatch();Start Laravel Horizon:
$ php artisan horizonSeeding the database :
$ php artisan db:seedRunning tests :
$ php artisan testRunning Laravel Pint :
$ ./vendor/bin/pint --verbose --testGenerating backup :
$ php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
$ php artisan backup:runGenerating fake data :
$ php artisan db:seed --class=DevDatabaseSeederDiscover package
$ php artisan package:discoverIn development environment, rebuild the database :
$ php artisan migrate:fresh --seedClients can access to the REST API. API requests require authentication via Bearer token.
Generate a new token:
curl --location --request POST 'laravel-blog.test/api/v1/authenticate?email=your_email&password=your_password' \
--header 'X-Requested-With: XMLHttpRequest'And now you can use the meta.access_token key as your Bearer token:
curl --location 'laravel-blog.test/api/v1/posts' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Authorization: Bearer access_token'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 :
$ php artisan route:list --path=apiDo 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.