Notes to Set Up a New Laravel Project

November 14, 2021

Set up a new project

curl -s ",redis,minio,mailhog" | bash

Know more about the services at

Code Analysis

Go inside the folder, and create a new bin folder, then bring some useful tools: mkdir bin and cd bin

PHP Mess Detector:

wget -c

Configuration file: phpmd.xml

PHP Code Sniffer:



Configuration file: phpcs.xml

PHP Copy & Paste Detector:


If not, it would be good to create some aliases to help:

  alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
  alias shell="sail shell"
  alias shellr="sail root-shell"
  alias tinker="sail tinker"
  alias dusk="sail dusk"
  alias sn="sail node"
  alias snpm="sail npm"
  alias sc="sail composer"
  alias sp="sail php"
  alias a="sail artisan"
  alias p="sail test"
  alias pf="sp ./vendor/bin/phpunit --filter "

Start sail: sail up (or sail up -d)

Require the Laravel Debugbar:

sc require barryvdh/laravel-debugbar --dev

Require and set up the Psalm:

sc require --dev vimeo/psalm sp ./vendor/bin/psalm --init

sc require --dev psalm/plugin-laravel sp ./vendor/bin/psalm-plugin enable psalm/plugin-laravel

Adding scripts in composer

Add the following scripts in the composer.json (this will help the CI/CD):

    "scripts": {
        "package:outdated": "@composer outdated -D -f json",
        "test:run": "./vendor/bin/phpunit",
        "test:coverage": "@test:run --coverage-html tests/report",
        "phpcs:check": "php ./bin/phpcs.phar ./phpcs.xml app/",
        "phpcs:fix": "php ./bin/phpcbf.phar ./phpcs.xml app/",
        "phpmd:check": "php ./bin/phpmd.phar app/ ansi ./phpmd.xml",
        "phpcpd:check": "php ./bin/phpcpd.phar app/",
        "psalm:check": "php ./vendor/bin/psalm",

Publish Stubs/Resources

I like to clean up my stubs, removing some comments an adding some missing types:

a stub:publish

If running Livewire: livewire:stubs

I also publish some items that I like to have control over:

a publish:vendor

Then publish: laravel-mail laravel-notification laravel-pagination

If running Livewire: livewire

Environment Variables

The variables I change in the .env file:

APP_NAME={proper value}
APP_URL={proper value}


MAIL_FROM_ADDRESS={proper value}


Config Minio

As the .env above, go to the Minio, and create a new public bucket called local


Remove the DB_ comments on phpunit.xml, as for most of the cases using sqlite is good enough.

To run tests:

p It will run all test suite

pf something It will run tests with something (--filter)

sc test:coverage It will run tests with coverage. The files will be in the /tests/report

(Do not forget to add /tests/report in the .gitignore file)

Mauro Baptista

Mauro Baptista

Building stuff with code and having fun in the way

© 2022, Built with Gatsby