This is the API for the five things app, i'll also later on use it as a base api for other apps
This repository houses a template API built using Laravel, it was created to help me quickly to quickly bootstrap an API project.
Right now the repository has the following functionality
- [*] API authentication using Laravel Passport.
- [*] Authorization using spatie/laravel-permission.
- [*] Activity logging using spatie/laravel-activitylog.
- [*] GraphQL server using nuwave/lighthouse.
- [*] A CI/CD pipeline using Github Actions.
- [*] Automated tests for existing functionality.
-
Clone the repository using the following command:
git clone https://github.com/omadoyeabraham/laravel-template-api.git
-
Configure the project using the following command:
sh ./tools/configure.sh
The command does the following:
- Installs composer dependencies
- Creates a .env file with the content
local
. This will tell the app which environment the app will run - Creates a copies the contents from ./envs/example/.env to ./envs/local/.env
- Generates the laravel app key using
php artisan key:generate
-
Ensure that you fill the variables in
/envs/local/.env
with your credentials and values. -
Ensure you have docker installed and running.
-
Go through
docker-compose.yml
and change the default port numbers and database credentials as necessary. -
If you changed the database and redis credentials/ports in
docker-compose.yml
ensure you change it in/envs/local/.env
also.Note that the ports in
/envs/local/,env
will be the ports exposed by docker e.g. if the postgres image has port credentials"3434:5432"
, then use3434
in the/envs/local/.env
file. -
Spin up the app, postgresql and redis containers using the following command:
docker-compose up
-
Run the script used to migrate and seed the database, and also install laravel passport.
sh ./tools/prepare-local-database.sh
-
To setup AWS credentials to be used for serverless deployment from Github Actions CI/CD pipeline, the following secret variables have to be set on the Github repository
- AwsAccessKeyId
- AwsSecretAccessKey
-
Setup the environment variables in
serverless.yml
on AWS SSM so that serverless functions can use them.