Every time I'm installing a fresh Laravel project, I find myself following the same steps over and over again. As I've written them out (so it's easier for me to execute them without forgetting anything), I see nothing but advantages with sharing it. Eager to learn from your feedback!
Keep in mind, this is an opinionated (it's all about what I think is standardly needed in setting up a fresh project) recipe. Though originally written down for a Laravel 9 project, I don't see any reason why it wouldn't work for a Laravel 10 project.
A. Basic installation
- Install the app scaffolding
composer create-project laravel/laravel PROJECTNAME
cd PROJECTNAME
-
Replace
README.md
with a correct version (tip: readme.so, makeareadme.com), update the top section ofcomposer.json
, so that it reflects this project. -
Initialise a fresh git repository
git init
git add .
git commit -m "START :seedling: Initial commit"
And connect it to Github to ensure backup.
- Create database + update
.env
+ test connection by migrating
php artisan migrate
- Install Breeze (for authentication and ready-made Tailwind scaffolding & Vite)
composer require laravel/breeze --dev
php artisan breeze:install
This will also trigger an npm install. Next commit changes:
git add . & git commit -m "FEATURE :sparkles: Add & install Breeze"
- Installing tooling* for local development
composer require spatie/laravel-ray
composer require barryvdh/laravel-debugbar --dev
Add HELO settings to .env (and .env.example).
Add some extra security
composer require --dev roave/security-advisories:dev-latest
And commit those changes:
git add . & git commit -m "FEATURE :sparkles: Add development tooling"
Disclaimer: both myray.app and usehelo.com are paid tools, but they are so good that I can't miss them.
- Make sure that the front-end assets are up-to-date. Get latest version of Tailwind CSS (and include the modules)
npm install -D tailwindcss@latest @tailwindcss/typography@latest @tailwindcss/forms@latest @tailwindcss/aspect-ratio@latest @tailwindcss/line-clamp@latest postcss@latest autoprefixer@latest
Get the latest version of Vite & AlpineJs
npm install -D vite@latest laravel-vite-plugin@latest
npm install alpinejs@latest
Update resource/app.js
(basically I remove the bootstrap.js, as I typically don't need any axios functionality) to look like:
import Alpine from 'alpinejs'
window.Alpine = Alpine
Alpine.start()
And commit changes:
git add . & git commit -m "UPDATE :package: Bump to latest versions of the packages"
B. Add proprietary tooling
Of course not disclosed here :-). But this is where I import my back-end admin tooling that is being used in almost every project
C. Correct language settings
-
Set the correct main language in
\config\app.php
. (keys:locale
,fallback_locale
&faker_locale
). -
Install and use laravel-lang/lang to assure that all the boilerplate (auth, validation etc) is in the correct language for the app - nl in the snippet below
composer require laravel-lang/lang --dev
composer require laravel-lang/publisher laravel-lang/lang laravel-lang/attributes --dev
php artisan lang:add nl
- And commit changes:
git add . & git commit -m "FEATURE:sparkles: Correct language settings"
Where to take it from here?
Of course I could go even faster by creating my own application scaffolding and start from that boilerplate. So that, after a clean install, I'm immediately at the end of this article by typing composer create-project myorganisation/laravel_scaffolding PROJECTNAME
.
I choose not to do this, as I like to stay as close as possible to the original core application at any time. And often there are small nuances in the scripts to execute. So a recipe to follow currently still is my preferred way of working.
Did you spot mistakes, or things I forgot? Feel free to let me know!