keep const value in Symfony

  const, php, rest, symfony, symfony4

Here is the problem:

I have been trying to keep the value of a const variable if is defined in app.php in Symfony. This is my code.

The design of the app was made it like this. with a constant that indicates what type of system to start.
This is my code.

if(!defined("ENTORNO")) {

i’m using “true” to redefine the const value. I have a REST service to redefine the const variable. Like this.

     * @RestGet("/api/VersionSistema/{id}", name="VersionSistemas")
public function VersionSistemas($id)
    try {
        return new View(Response::HTTP_OK);
    } catch (Exception $e) {
        return new View($e->getMessage(), Response::HTTP_BAD_REQUEST);

My problem is that in each request the variable loses its value and is reinitialized. So ┬┐how could I always keep the value with which I redefined the variable?

Source: Symfony Questions