3sidedcube / laravel-api-template
A template for creating new Laravel API projects.
Requires
- php: ^8.1
- 3sidedcube/laravel-api-errors: ^1.1
- 3sidedcube/laravel-redoc: ^1.0
- bepsvpt/secure-headers: ^7.2
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^9.2
- laravel/sanctum: ^2.14.2
- laravel/tinker: ^2.7
- sentry/sentry-laravel: ^2.11
Requires (Dev)
- brianium/paratest: ^6.4
- fakerphp/faker: ^1.9.1
- friendsofphp/php-cs-fixer: ^3.6
- laravel/sail: ^1.0.1
- mockery/mockery: ^1.4.4
- nunomaduro/collision: ^6.1
- phpunit/phpunit: ^9.5.10
- spatie/laravel-ignition: ^1.0
README
:project_name
This repository can be used to scaffold new Laravel APIs. Follow these steps to get started:
- Run the following command in your terminal:
composer create-project 3sidedcube/laravel-api-template project-name -s dev
- Next configure your Laravel services by running:
php artisan sail:install
- Update the
bitbucket-pipelines.yml
file to use any additional services - Ensure that the provisioning and deployment information is correct
- Create a Backend API confluence page on the project space for writing helpful documentation (remember to update the README)
- Replace any references to project_name with your project name. You will need to update the following files:
composer.json
(name)- README.md (title)
- Environment variables (
.env
,.env.example
,.env.pipelines
) - OpenAPI (
v1.json
) - Changelog
- 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
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
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
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
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
- Copy the example environment file:
cp .env.example .env
- 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
- 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
- The API should now be available at http://localhost.
Stopping the project
- To stop the project docker containers, simply run the following command:
./vendor/bin/sail down
Starting the project again
- 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