Search by

experteam / api-base-bundle

experteam-mx

Base functionality bundle for APIs

Package info

github.com/experteam-mx/api-base-bundle

Type:symfony-bundle

pkg:composer/experteam/api-base-bundle

Statistics

Installs: 14 494

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

5.0.2 2026-11-27 01:18 UTC

README

Base Services for APIs in Symfony 5.1+
It includes:

  • Params Client: Service to obtain the value of parameters defined in api-companies.
  • JSend Response: Sets the format of the JSON response according to the JSEND specification (https://github.com/omniti-labs/jsend).
  • Request Util: Request validation service.

Install

  1. Run de following composer command:
composer require experteam/api-base-bundle
  1. Create the configuration file through any of the following options:

    a. Manually copy the example file in the package root to the folder config/packages/.

    b. Copy the vendor_copy.php file to the root of the project and configure the scripts in the composer.json file:

    "scripts": {
         "vendor-scripts": [
             "@php vendor_copy.php -s vendor/experteam/api-base-bundle/experteam_api_base.yaml.example -d config/packages/experteam_api_base.yaml --not-overwrite --ignore-no-source"
         ],
         "post-install-cmd": [
             "@vendor-scripts"
         ],
         "post-update-cmd": [
             "@vendor-scripts"
         ]
     },
    
  2. Edit the bundle configuration file config/packages/experteam_api_base.yaml:

experteam_api_base:
    params:
        remote:
            enabled: [Enabled]
            url: [URL]
        defaults:
            [PARAM NAME]: [Value]
            [PARAM NAME]: [Value]

Update

Run de following composer command:

composer update experteam/api-base-bundle

Supervisor FATAL alert

experteam:supervisor:fatal-alert is a Supervisor event listener. When a worker reaches FATAL it emails support and logs the event to ELK. A rejected or unreachable email is logged too.

The email goes by Symfony Mailer when the API has it, and otherwise through the API Services email route. Either way it retries once on a transport error. Configure the sender for Mailer, or the route and its key for API Services:

experteam_api_base:
    supervisor_alert:
        sender_address: '%env(MAILER_FROM_ADDRESS)%'
        sender_name: '%env(MAILER_FROM_NAME)%'
experteam_api_base:
    supervisor_alert:
        remote_url: '%env(APIS_SERVICES_URL)%/emails'
        app_key: '%env(AUTH_MASTER_APP_KEY)%'

Add the listener in the same change that requires this version. Without the command the listener never starts: it ends in FATAL, or respawns without end when PHP takes longer than startsecs to fail. Register it in deploy/supervisor, with its logs in the /var/log/supervisord.log.d pod volume so they survive a container restart:

[eventlistener:supervisor_fatal_alert]
command=php -d display_errors=stderr /opt/app-root/src/bin/console experteam:supervisor:fatal-alert --no-interaction
events=PROCESS_STATE_FATAL
buffer_size=50
autostart=true
autorestart=true
startsecs=1
startretries=35
stderr_logfile=/var/log/supervisord.log.d/supervisor_fatal_alert.err.log
stdout_logfile=/var/log/supervisord.log.d/supervisor_fatal_alert.out.log

The listener's stdout carries the Supervisor protocol, so nothing else in the process may write to it. A stray line makes Supervisor stop sending events while the process keeps running.

The email points support to /var/log/supervisord.log.d/supervisor_<program>.err.log, so name each worker's stderr_logfile after its program.

It reads the recipient from SUPERVISOR_FATAL_ALERT_EMAIL, crasupport@experteam.com.ec when it is not set, and the namespace from MY_POD_NAMESPACE, which the deployment template sets from metadata.namespace. The pod name is the container host name. Run it with --test to send a test email.

The email is the HTML template in src/Resources/supervisor-fatal-alert.html, with the DHL colors and every value escaped. It uses Poppins where the mail client loads web fonts and Arial in Outlook.

The email tells support that OpenShift restarts the container on its own, which holds only when the deployment has the liveness probe that fails while a Supervisor program is FATAL.

License

MIT license.