The humble checklist is an incredible tool for quickly and accurately completing tasks that you don't do all of the time. Time and time again, checklists have saved me from making a critical error on some pretty important - and terribly mundane - tasks.
One of my all-time favorite checklists outlines how to set up and configure a new Laravel project. While the documentation does a great job of explaining how to get the ball rolling, there are still several things we need to do before we can really start working.
Without further ado, let's hop right into this checklist and configure a brand new Laravel project.
laravel new <project-name>
from the directory where we want to store our projectmysql -uroot -p
to log in to MySQLcreate database <database-name>;
to create the database.env
.env
file to configure our project, which we'll need to update.
APP_NAME=“<app-name>”
APP_URL=http://<dev-url>
DB_DATABASE=<database-name>
DB_USERNAME=root
DB_PASSWORD=
phpunit.xml
in the root directory of our project, we can add the following lines in the <php></php>
block at the bottom
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
php artisan make:auth
php artisan migrate
git init
to initialize the project as a git repositorygit add .
to add all of the project files to the staging areagit commit -m 'initial commit'
to commit these filesyarn
or npm install
to install your project's initial JavaScript dependencies.sass
files for my custom CSS, so at this point I'll make a few changes to do that. You don't have to this if you don't want to use Sass, but you might have to do some other work to use your CSS preprocessor of choice._variables.scss
fileapp.scss
app.scss
to use .sass
app.scss
inside of webpack.mix.js
yarn add tailwindcss --dev
or npm install tailwindcss --save-dev
to install the package./node_modules/.bin/tailwind init
to generate the config file@tailwind preflight
and @tailwind utilities
to app.sass
in that orderlet tailwindcss = require('tailwindcss');
to the top of webpack.mix.js
.sass()
portion of the mix code with the following:.sass('resources/assets/sass/app.sass', 'public/css').options({
processCssUrls: false, postCss:[ tailwindcss(‘./tailwind.js') ],
});
npm run production
to make sure everything is working correctly and to generate your CSS fileI hope this checklist can help you get a new Laravel project up and running, and show you how useful checklists can be. This isn't something that anyone does often, so having this checklist handy prevents us from making obvious mistakes that take time away from actually coding! As always, feel free to ask me any questions on Twitter. And until next time, happy coding!
I craft experiences that help people reach their full potential.
Interested in getting my latest content? Join my mailing list.
In step 4.1, I TDD the endpoints for the media models.
Watch stream