0

Amazon AWS have an official template for WordPress configuration file that uses the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'] syntax to set environment variables values to the application. And I have realized that the key in $_SERVER is always equals to a Linux environment variable, that I conveniently can setup in the web console. It would mean that I could also set the same custom variables in my development environment and in deployment make no changes in the code in terms of variables adjustments and neither worry about some configuration file that can be wrongly handled in the deployment process.

But actually, in my development environments the things almost works like this. I an working in a Laravel application, and the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'], as those related to the databases connection works file in the console commands. But, when running the application in a PHP server for development, those same variables does not works, and I receive the Undefined index error.

How does I set my local development environment, so that the local PHP server can understood the $_SERVER['SOME_CUSTOM_SYSTEM_VAR'], fetching variables from the operational system?

aynber
  • 22,380
  • 8
  • 50
  • 63
danilocgsilva
  • 187
  • 1
  • 13

1 Answers1

0

Find the location of your local systems php.ini file and update the system variable for the server so that the application can actually see it. Using the command line you have direct access to these types of things because they're loaded into a wrapper, in an application you do not.

Edit: You may also consider using your .env file if it's simply needing to be available to your Laravel app.

What exactly are you trying to set? And what does it get used for?

  • 1
    Thanks! But I just realized that the working flow that I was looking for does not needs the .env file. I was trying to make a mixed approach, where I use .env in development environment and in the production environment I use the system variables. But as I have full control over development system variables, and also have full control over the production system's variables, I do not need .env at all, and my software can be deployed without any change in the code, as the configurations values is not stored in any code place. – danilocgsilva Sep 20 '18 at 14:49