Skip to content

A Laravel project template to save you time and energy.

License

Notifications You must be signed in to change notification settings

Justintime50/laravel-template

Repository files navigation

Laravel Template

A Laravel project template to save you time and energy.

Build Licence

Showcase

Setup Template

  1. Click the Use this template button at the top of this project's GitHub page, it looks like this:

Showcase

  1. After using the template, clone the repo
  2. Laravel Template assumes you have composer installed globally:
# Install Laravel into a `src` directory
composer create-project laravel/laravel src

Text Replacement

Once Laravel is installed, replace text as needed throughout the project:

  1. Replace all instances of laravel-template with the name of your project (found in docker-compose files)
  2. Replace all values in src/.env to reflect the values you need
  3. Update name in LICENSE
  4. Uncomment and configure the .github/workflows/build.yml file
  5. Update the CHANGELOG
  6. Delete this README and create a new one for your project

Customization

  1. Change the session driver from file based to database
  2. Change the logging from stack to daily
  3. (Optional) Change the cache driver from file based to Redis

In the composer.json file, add the following:

  1. "bin-dir": "bin" to the config section
  2. Install PHP CodeSniffer: composer require --dev squizlabs/php_codesniffer
  3. Install larastan: composer require --dev larastan/larastan
  4. Install Justintime50 PHP styles via npm install --save-dev justintime50-styles
  5. Correct prod and dev dependencies as production builds won't contain dev deps
  6. Add the folllowing to the scripts section of the composer.json file:
"clean": "rm -rf bin clover.html node_modules vendor *.cache .*.cache bootstrap/cache/*.php",
"coverage": "XDEBUG_MODE=coverage ./bin/phpunit --coverage-html clover.html --coverage-clover clover.xml",
"clean-db": "docker exec -t laravel-template-laravel-template-1 php artisan db:wipe",
"fix": "./bin/phpcbf --standard=./node_modules/justintime50-styles/src/php/phpcs.xml .",
"lint": "./bin/phpcs --standard=./node_modules/justintime50-styles/src/php/phpcs.xml .",
"migrate-fresh": "docker exec -t laravel-template-laravel-template-1 php artisan migrate:fresh --no-interaction --force",
"migrate-seed": "docker exec -t laravel-template-laravel-template-1 php artisan migrate:fresh --seed --no-interaction --force",
"migrate": "docker exec -t laravel-template-laravel-template-1 php artisan migrate --no-interaction --force",
"phpstan": "./bin/phpstan analyse --memory-limit=2G",
"rollback": "docker exec -t laravel-template-laravel-template-1 php artisan migrate:rollback --no-interaction --force",
"seed": "docker exec -t laravel-template-laravel-template-1 php artisan db:seed --no-interaction --force",
"test": "./bin/phpunit"
  1. Add the following to the scripts section of the package.json file:
"lint": "npx stylelint resources/sass/*.scss --config node_modules/justintime50-styles/src/css/.stylelintrc.json --custom-syntax postcss-scss",
"fix": "npx stylelint resources/sass/*.scss --config node_modules/justintime50-styles/src/css/.stylelintrc.json --custom-syntax postcss-scss --fix"
  1. Create a phpstan.neon file with the following content:
includes:
    - vendor/larastan/larastan/extension.neon

parameters:
    paths:
        - app/
        - tests/
    level: 5

Install

# Copy the env files, and edit as needed
mv src/.env.example src/.env-example
cp src/.env-example src/.env && cp .env-example .env

# Move the justfile location
mv justfile src/justfile

# Run the setup script which will bootstrap all the requirements, spin up the service, and migrate the database
just setup

Usage

  1. Setup Traefik to manage routing and load balancing
  2. Setup DNSMasq so you don't have to manage your /etc/hosts file while using Traefik for local development

Deploy

# Deploy the project locally
just run

# Deploy the project in production
just prod

Development

The following commands may need to be manually added before they're ready to use.

# Get a comprehensive list of development tools
just --list

About

A Laravel project template to save you time and energy.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published