3sidedcube/laravel-api-template

A template for creating new Laravel API projects.

v0.4.0 2022-07-01 08:18 UTC

This package is auto-updated.

Last update: 2024-11-13 20:42:27 UTC


README

3 Sided Cube

:project_name

This repository can be used to scaffold new Laravel APIs. Follow these steps to get started:

  1. Run the following command in your terminal:
composer create-project 3sidedcube/laravel-api-template project-name -s dev
  1. Next configure your Laravel services by running:
php artisan sail:install
  1. Update the bitbucket-pipelines.yml file to use any additional services
  2. Ensure that the provisioning and deployment information is correct
  3. Create a Backend API confluence page on the project space for writing helpful documentation (remember to update the README)
  4. Replace any references to project_name with your project name. You will need to update the following files:
    1. composer.json (name)
    2. README.md (title)
    3. Environment variables (.env, .env.example, .env.pipelines)
    4. OpenAPI (v1.json)
    5. Changelog
  5. Update the environment information below with the correct URLs

This is where your description should go. Limit it to a paragraph or two.

Environments

There are several environments available for this project.

Production

https://project-api.com

This environment should only be used for production builds. Changes to the API should have been tested before they are deployed to this environment.

Staging

https://project-api.com

Once the API has completed internal testing, it should be deployed to this environment. This will then be used by the client during UAT.

Note: Please ensure that UAT always used this environment so that bug fixes and changes can be deployed to test whilst UAT is ongoing.

Test

https://project-api.com

The test environment should be used for testing the API internally All mobile builds that are built for the testing team should also point at this environment.

Development

https://project-api.com

This environment is available for mobile developers or frontend developers to use when developing new features locally. It is helpful to have the environment so that developers can fix any breaking changes before the API changes get deployed to the test environment.

Local Development

This project uses Laravel Sail for local development which uses Docker. You will need to ensure that you have Docker installed and running on your machine.

First time setup

  1. Copy the example environment file:
cp .env.example .env
  1. Install Composer dependencies:
docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/opt \
    -w /opt \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs
  1. Run the following commands:
./vendor/bin/sail up -d
./vendor/bin/sail artisan key:generate
./vendor/bin/sail artisan migrate
./vendor/bin/sail artisan db:seed
  1. The API should now be available at http://localhost.

Stopping the project

  1. To stop the project docker containers, simply run the following command:
./vendor/bin/sail down

Starting the project again

  1. To start the project docker containers after you've completed the first time use, simply run the following command:
./vendor/bin/sail up -d

Gotchas

Here are some helpful tips if you are having issues with this project:

Provisioning

Server provisioning is handled by Laravel Forge.

Deployments

To deploy this project, login to Envoyer and click deploy on the corresponding project.

Documentation

All documentation can be found under the following page in confluence.

Logging

We use Sentry for keeping track of logs across the various environments.

Tests

You can run the full test suite by running the following command:

make test