This repository is a "template" repository, and is intended to be used to create a new repo.
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:
- PHP 8.1
- JSON extension
- mbstring extension
- openssl extension
- PDO extension (for Postgres and Sqlite)
- 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"
- Language: PHP
- Framework: Laravel
- Database: PostgreSql
- Git : Install git
- To clone the repo created using this template repo (or even the boilerplate)
- Docker : Install docker
- Docker Compose : Install docker-compose
- 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 forSuper Awesome Website - API
- The URL of the repo would now be :
https://github.com/founderandlightning/saw-api.git
git clone git@github.com:founderandlightning/saw-api.git
cd saw-api
Update the service and container names in docker-compose.yml
to avoid conflicts with other projects using the same template
- From
laravel-api
tosaw-api
- From
larave-pg
tosaw-pg
docker-compose up --build -d
- Install composer dependencies
docker-compose exec saw-api composer install
http://210.101.1.1
- 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 indocker-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'
- APP_DEBUG:
- 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
- Root password, as
- 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)
- laravel-api
- 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)
Below are the features of boilerplate compared to the default laravel app
-
setup Docker
- setup 2 containers
- web container: apache with PHP 8
- DB container: postgres latest version (at the time of writing it is postgres version 14)
-
- runs DB migrations
- defines 2 process types: web and worker
- web: apache server
- worker: starts laravel queue worker if there's a worker dyno on heroku
-
-
Pre-commit hook
-
Pre-push hook
-
-
- Telescope is enabled on all environments
- To disable on particular environment, we can set env variable
TELESCOPE_ENABLED = false
-
- For VSCode, an extra extension is required for auto-completion to work - PHP Intelephense
-
- Set env variable
ROLLBAR_ACCESS_TOKEN
- Set env variable