/wink

Primary LanguagePHP

Laravel boilerplate repository

This repository is a "template" repository, and is intended to be used to create a new repository.

It contains the basic packages that are required in all projects (almost all), and can be changed as per the requirements of the project.

The dependencies and packages (some of these are mentioned in composer.json) are included in the Dockerfile, and are listed below:

Dependencies:

  • PHP 8.1
  • JSON extension
  • mbstring extension
  • openssl extension
  • PDO extension (for Postgres and Sqlite)

Packages:

  • fruitcake/laravel-cors : ^2.0
  • guzzlehttp/guzzle : ^7.0.1
  • laravel/framework : ^8.54
  • laravel/sanctum : ^2.11
  • laravel/telescope : ^4.6
  • laravel/tinker : ^2.5
  • rollbar/rollbar-laravel : ^7.0"

Core technologies for development

  • Language: PHP
  • Framework: Laravel
  • Database: PostgreSql

Basic requirements for setup

Using the template to create a new repo

  • Click the button on the top that says "Use this template" and on the following page enter the repository name.
  • The sample name that we would use is saw-api short for Super Awesome Website - API
  • The URL of the repo would now be : https://github.com/founderandlightning/saw-api.git

Clone and setup the project

Get the code (clone the repo)

git clone git@github.com:founderandlightning/saw-api.git

Enter the folder :

cd saw-api

Update service names

Update the service and container names in docker-compose.yml to avoid conflicts with other projects using the same template

  • From laravel-api to saw-api
  • From larave-pg to saw-pg

Make the docker-compose build and bring up the services, in the background

docker-compose up --build -d

Install the boilerplate

  • Install composer dependencies
docker-compose exec saw-api composer install

The landing page URL should be working now

http://210.101.1.1

Breakdown of the docker-compose.yml file

  • Version: 3
  • Services:
    • laravel-api
      • Uses the commands mentioned in Dockerfile to build the docker image
      • Uses the same name for container laravel-api
      • Requires the DB service (laravel-pg) to be up and running
      • The current directory (".") is mapped to the webroot of container, to keep files in sync (file-permissions still might need to be managed manually)
      • Restart the container, so that docker-compose up will reflect the changes made in docker-compose.yml, and additionally it also ensures that the services are started with the system/daemon start-up (basically, auto-start docker service with system boot-up)
      • Some environment variables are setup already
        • APP_DEBUG: 'true'
        • APP_NAME: 'F+L Laravel Boilerplate'
        • APP_ENV: 'local'
        • APP_URL: 'http://210.101.1.1'
        • DB_CONNECTION: 'pgsql'
      • IP address is mentioned (belonging to a specific network)
    • laravel-pg
      • Uses the latest postgres image (from Docker hub)
      • There are 2 environment variables
        • Root password, as docker
        • Create secondary DB as test_db for PhpUnit test cases
      • Uses the same name for container laravel-pg
      • The container's data storage folder is mapped to a volume in host machine; this ensures DB is not deleted when the container is removed
      • IP address is mentioned (belonging to a specific network)
  • Volume: Creates a volume on host machine, and is used by laravel-pg service to store DB data
  • Network : Network specific details (primarily the subnet IP range)

Features of boilerplate

Below are the features of boilerplate compared to the default laravel app