Laravel EMS Backend Integration
This folder documents the Laravel changes required in the ems-frontend container to communicate with the Python EMS service running in the ems-backend container.
Goal
Laravel is the public application API. It forwards requests server-side to Python EMS:
Browser -> Laravel (ems-frontend) -> Python EMS (ems-backend:8080)
The browser must not call ems-backend directly because Docker service names are normally resolvable only inside the Docker network.
The documentation files live in this laravel/ folder. The copy-paste code files
referenced below remain in the source tree at
EnergySyc_EMS_ES100Cx12S/laravel_dev_help/.
Files in this handoff
| File | Copy into Laravel |
|---|---|
.env.example.additions |
Add values to Laravel .env |
config_services.php.snippet |
Merge into config/services.php |
EmsBackendController.php.snippet |
app/Http/Controllers/EmsBackendController.php |
routes_api.php.snippet |
Merge into routes/api.php |
frontend_usage.md |
Frontend calls and response handling |
deployment_and_testing.md |
Docker deployment and verification |
api_contract.md |
Endpoint and payload reference |
Installation order
- Add the environment variables.
- Add the
services.ems_backendconfiguration. - Copy the controller.
- Add the API routes.
- Run
php artisan config:clearandphp artisan route:clear. - Test connectivity from inside
ems-frontend. - Update the frontend to call Laravel
/api/ems/*routes.
Important settings behavior
PUT /api/ems/settings must receive the complete settings JSON object. The Python backend replaces the settings cache atomically and the EMS uses it on the next control cycle. Do not send only one nested section unless the Laravel controller first merges it with the current settings object.
Feature pages
- Diagnostic Test Debug Dashboard — the admin blade for activating EMS diagnostic tests and viewing their results.