┏━━━┓━━━━━━━━━━━━━┏┓━━━━━━━━━━━━━━━━━━━━━━━┏━━┓━━━━━━━━━━┏┓━━━━━━━━━━━━┏┓
┃┏━┓┃━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━┃┏┓┃━━━━━━━━━━┃┃━━━━━━━━━━━━┃┃
┃┃━┗┛┏━━┓┏━━┓┏━┓┏━┛┃┏┓┏━┓━┏━━┓━┏━━┓┏━━┓━━━━┃┗┛┗┓┏━━┓━┏━━┓┃┃┏┓┏━━┓┏━┓━┏━┛┃
┃┃━┏┓┃┏┓┃┃┏┓┃┃┏┛┃┏┓┃┣┫┃┏┓┓┗━┓┃━┃┏┓┃┃┏┓┃━━━━┃┏━┓┃┗━┓┃━┃┏━┛┃┗┛┛┃┏┓┃┃┏┓┓┃┏┓┃
┃┗━┛┃┃┗┛┃┃┗┛┃┃┃━┃┗┛┃┃┃┃┃┃┃┃┗┛┗┓┃┗┛┃┃┃━┫━━━━┃┗━┛┃┃┗┛┗┓┃┗━┓┃┏┓┓┃┃━┫┃┃┃┃┃┗┛┃
┗━━━┛┗━━┛┗━━┛┗┛━┗━━┛┗┛┗┛┗┛┗━━━┛┃┏━┛┗━━┛━━━━┗━━━┛┗━━━┛┗━━┛┗┛┗┛┗━━┛┗┛┗┛┗━━┛
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
.--.
.- \
/_ \
(o )
_/ |
(c .-. |
___ ;; / .' \
.'' ``. ;; O) | \
_/ .-. .-. \_ () () / _ `.__ \ \
(o|( O O )|o) ()(O)() |/ ) / \ \
.' `. ()\ _|_ / \ \
/ (c c) \ \(_ \ / \ \
| | (__) `.______ ( ._/ \ )
\ (o) / (___)`._ .' ) /
`. .' (__) ______ / / /
`-.___.-' /|\ | / /
___)(___ / \ \ / /
.-' `-. `. .' /
/ .-. .-. \ `- /.' /
/ / ( . . ) \ \ / \)| | | |
/ / \ / \ \ / \_\_\_)
\ \ ) ( / / ( /
\ \ ( __ ) / / \ \ \ \
/ ) // \\ ( \ \ \ \ \
(\ / / /\) \\ // (/\ \ \ /) ) \ \ \
-'-'-' .' )( `. `-`-`- .' |.' |
.'_ .' `. _`. _.--' ( (
MJP oOO(_) (_)OOo (__.--._____)_____)
This repository contains the ape-backend codebase which serves the Coordinape API.
This is a project written in PHP using the Laravel PHP framework. The database is mysql. Docker is used to setup the environment.
Welcome! We're so glad you're reading this and want to contribute! This section will get your dev environment setup.
This app uses Docker.
- Install Docker: https://docs.docker.com/engine/install/
Once docker is installed and and the docker daemon is running you can check your docker version:
> docker --version
Docker version 20.10.7, build f0df350
- Setup your
.env
file by copying the example environment file:
cp .env.example .env
- Use docker compose to launch the three containers required for the app to run:
cd coordinape-backend
docker compose up
This can take a while to build the Dockerfile and install all the app dependencies into vendor/
.
- Now you need to populate your local database with some data.
- Option 0: create data through console command.
docker exec app php artisan ape:quickstart youraddresshere
-
Option 1: create data in the database directly.
- Create a protocol
- Create a circle - link to protocol_id
- Create a user - link circle_id to circle, address=your_address,role = 1 (for admin access)
- Create profile - just need an address
-
Option 2: restore database from a staging db dump (get from another dev)
docker exec -i mysql mysql -uroot -psecret laravel < database/db_dumps/staging_db_dump.sql
If you want to explore the MySQL database you can download a UI for MySQL such as Sequel Ace.
You can connect to the database with Sequel Ace using this default connection details:
Name: coordinape mysql
Host: 127.0.0.1
Username: root
Password: secret
Database: laravel
Port: 3306
Ok, so you followed this guide but you're getting an error. Oops. If you see your error below, try the solution posted below. If you do not see your error below, and after some research you find a solution, consider adding it to this section. It will help the next person.
If you're getting an error from the API like:
Warning: require(/var/www/public/../vendor/autoload.php): Failed to open stream: No such file or directory in /var/www/public/index.php on line 34
Fatal error: Uncaught Error: Failed opening required '/var/www/public/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/public/index.php:34 Stack trace: #0 {main} thrown in /var/www/public/index.php on line 34
This is probably because you don' thave all the packages installed properly in laravel. Fix with running composer update
> docker exec -it app composer update
This error likely is a result of the MySQL database not being properly setup and migrated
"message": "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel.protocols' doesn't exist (SQL: select * from `protocols`)",
Try doing a full fresh migrate and seed with:
docker exec -it app php artisan migrate:fresh --seed
Laravel logs errors to /var/www/storage/logs/laravel.log
on the docker host.
View detailed error logs by running this docker command:
docker exec -it app tail -f /var/www/storage/logs/laravel.log