Skip to content

Getting Started

Marina edited this page Oct 17, 2021 · 5 revisions

Live API can be found here:

https://saytheirnames.dev

Get the code

git clone https://github.com/Say-Their-Name/api.git
cd api

For this to work, you will need:

  • php7.2 or higher
  • mysql
  • composer

on your system.

Overall setup

Do not do this directly. See Setup with Docker below.

cd into project root and run the following:

// Create your environment file
cp .env.example .env

// install PHP dependancies
composer install

// create an encryption key
php artisan migrate

// create a database file
touch database/database.sqlite

// make sure the database driver is set to sqlite in the .env file
open .env and change:

DB_CONNECTION=mysql

to

DB_CONNECTION=sqlite

// run migrations to set up database and include dummy data
php artisan migrate:fresh --seed

// Run the local server 
php artisan serve

Setup with Docker

This is the recommended setup,as it prevents many PHP or dependency issues (compatibility, missing PHP extension...).

Requirements

Initial setup,with Taskfile (recommended)

git clone https://github.com/Say-Their-Name/api.git
cd api

# Build the development Docker image
task build

# Start the stack
task

# Install vendor dependencies
task vendor

# Prepare the database
task dbreset

# Run shell in the running container
task sh

## from shell you can run composer, artisan, etc

Go to http://localhost:8000

Adminer (Web UI for MySQL DB)

It's accessible at http://localhost:48080
Login using the user/password from the .env.example (should be stn/stn)


If Docker setup isn't possible, other ways to setup are available here

Endpoints Available

GET People
List all
http://localhost:8000/api/people

Get Single
http://localhost:8000/api/people/{firstname-lastname}

Filter by name
http://localhost:8000/api/people?name=george-floyd

Filter by country
http://localhost:8000/api/people?country=united-states

Filter by city
http://localhost:8000/api/people?city=minnesota

GET Donations
List Types
http://localhost:8000/api/donation-types

List all
http://localhost:8000/api/donations

Get Single
http://localhost:8000/api/donations/{slug}

Filter by Type
http://localhost:8000/api/donations?type=victims

Filter by Victim
http://localhost:8000/api/donations?name=george-floyd

GET Petitions
List Types
http://localhost:8000/api/petition-types

List All
http://localhost:8000/api/petitions

Get Single
http://localhost:8000/api/petitions/{slug}

Filter by Type
http://localhost:8000/api/petitions?type=victims

Filter by Person
http://localhost:8000/api/petitions?name=george-floyd