Files
ewaste-backend/README.md
floofyjin f8f6c2c112 add key for access laravel server.
modified readme to reflect what is needed for new users
2025-10-30 00:43:50 -07:00

84 lines
1.6 KiB
Markdown

# E-Waste Backend
## Installation
Clone the repo.
### 1a. Docker (Recommended)
It's recommended to use Docker to set up the development environment. It's literally one command:
```bash
docker compose up -d
```
From this point onward, run all shell commands inside the `ewaste-backend-laravel-1` container. The easiest way to do this is through your IDE's Docker extension, but the manual way is:
```bash
docker exec -it ewaste-backend-laravel-1 /bin/bash
```
### 1b. Manual
Alternatively, you can install PHP 8 (with the relevant extensions), PHP Composer, and Postgres on your system, then go into this directory and run:
```bash
composer install
```
### 2. Migrations
Apply all migrations to the database:
```bash
php artisan migrate
```
### 3. Generate key
Your .env should look something like this prior to running the command:
```
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
APP_KEY=
```
Generate Artisan key necessary for accessing endpoint:
```bash
exec laravel php artisan key:generate
```
**Note:** this step has to be redone every time a new database migration is written.
## Development
### Dev Server
To start the Laravel dev server, run this *inside* the Docker container:
```bash
composer run dev
```
Then you can go to http://localhost:8000 in your browser, like it says. The site will live update any time you make changes.
### Changing Docker Configs
If you change the Dockerfile, run this *outside* the Docker container:
```bash
docker compose up --build -d
```
If you change the docker-compose.yml file, run this *outside* the Docker container:
```bash
docker compose restart
```