Skip to content

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

  1. Add the environment variables.
  2. Add the services.ems_backend configuration.
  3. Copy the controller.
  4. Add the API routes.
  5. Run php artisan config:clear and php artisan route:clear.
  6. Test connectivity from inside ems-frontend.
  7. 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