Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GaelCeballos/Smart_Enviro_Backend/llms.txt

Use this file to discover all available pages before exploring further.

Smart Enviro Backend ships with a production-ready Dockerfile based on the official php:8.4-apache image. The build installs all system-level dependencies, compiles the PHP extensions required by Laravel (pdo_mysql, mbstring, exif, pcntl, bcmath, gd), enables Apache’s mod_rewrite module for clean URL routing, and sets the Apache document root to Laravel’s public/ directory. Composer dependencies are installed without dev packages using --no-dev --optimize-autoloader, and storage directories are pre-configured with the correct www-data ownership and 775 permissions.

Environment Variables

Configure your .env (or equivalent secrets manager) with the following variables before starting any container.

App

VariableDefaultDescription
APP_NAMELaravelHuman-readable application name.
APP_ENVlocalSet to production in live deployments.
APP_KEY(empty)Base-64 encryption key — generate with artisan key:generate.
APP_DEBUGtrueSet to false in production to suppress stack traces.
APP_URLhttp://localhostPublicly accessible base URL of the API.

Database

VariableDefaultDescription
DB_CONNECTIONsqliteSet to mysql when using the MySQL container.
DB_HOST127.0.0.1Hostname of the MySQL service (e.g. mysql inside Sail).
DB_PORT3306MySQL port.
DB_DATABASElaravelName of the target database.
DB_USERNAMErootMySQL user.
DB_PASSWORD(empty)MySQL password.

Redis

VariableDefaultDescription
REDIS_CLIENTphpredisPHP Redis driver — phpredis or predis.
REDIS_HOST127.0.0.1Hostname of the Redis service (e.g. redis inside Sail).
REDIS_PASSWORDnullRedis AUTH password; null disables authentication.
REDIS_PORT6379Redis port.

Cache / Queue / Session

VariableDefaultDescription
CACHE_STOREdatabaseCache backend — switch to redis for better performance.
QUEUE_CONNECTIONdatabaseQueue driver — switch to redis for a dedicated queue.
SESSION_DRIVERdatabaseSession storage backend.

Mail

VariableDefaultDescription
MAIL_MAILERlogMail transport — log writes to Laravel logs, use smtp in production.
MAIL_HOST127.0.0.1SMTP server hostname.
MAIL_PORT2525SMTP port.
MAIL_USERNAMEnullSMTP authentication username.
MAIL_PASSWORDnullSMTP authentication password.

Laravel Sail (Development)

Laravel Sail orchestrates the app, MySQL 8.4, and Redis Alpine containers via Docker Compose. It is the recommended workflow for local development and staging environments.
1

Configure environment variables

Copy .env.example to .env and update the database and Redis credentials:
cp .env.example .env
At minimum, set DB_CONNECTION=mysql and uncomment and fill in DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.
2

Start all services

./vendor/bin/sail up -d
Sail starts three containers in the background. Services are exposed on the following host ports:
ServiceEnvironment variableDefault port
Laravel appAPP_PORT80
MySQL 8.4FORWARD_DB_PORT3306
Redis AlpineFORWARD_REDIS_PORT6379
Override any port by setting the corresponding variable in .env before running sail up.
3

Generate the application key

./vendor/bin/sail artisan key:generate
4

Run database migrations

./vendor/bin/sail artisan migrate
5

Verify health

./vendor/bin/sail ps
All three services should show a healthy status. If the MySQL container is still initialising, wait a few seconds and try again.

Production Docker Build

Use the included Dockerfile to build a self-contained image suitable for any container platform (Docker Engine, ECS, Cloud Run, Fly.io, etc.). Build the image:
docker build -t smart-enviro-backend .
Run the container:
docker run -d -p 80:80 --env-file .env smart-enviro-backend
The Dockerfile does not run artisan migrate automatically. After starting the container, run migrations against your target database:
docker exec <container_id> php artisan migrate --force
In orchestrated environments (Kubernetes, ECS) this is best handled as an init container or a one-off task before the main container starts receiving traffic.

Post-Deploy Checklist

1

Set production environment flags

Ensure the following values are set in your production .env or secrets manager:
APP_ENV=production
APP_DEBUG=false
APP_DEBUG=false prevents sensitive stack traces and configuration details from leaking in API error responses.
2

Run database migrations

php artisan migrate --force
The --force flag is required to bypass the interactive prompt that Laravel shows when running migrations in production.
3

Set storage permissions

The Dockerfile pre-sets permissions for storage/ and bootstrap/cache/, but if you mount a volume over these directories in production you may need to re-apply:
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
4

Configure a queue worker

If you switch QUEUE_CONNECTION to redis, start a queue worker to process background jobs:
php artisan queue:work --tries=3
In production, manage this process with a supervisor such as Supervisor, systemd, or a sidecar container.

Code Quality

Run the following commands before building a production image to ensure the codebase is correctly formatted and all tests pass. Auto-format with Laravel Pint:
./vendor/bin/sail exec laravel.test ./vendor/bin/pint
Pint reformats PHP files to the project’s configured style rules. Commit any resulting changes before pushing. Run the Pest test suite:
./vendor/bin/sail artisan test
All Feature and Unit tests must pass before a build is promoted to production. A failed test in CI should block the deployment pipeline.

Build docs developers (and LLMs) love