We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Native multi-environment support

Feature Requests

Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Transferring from impdesigns in Slack:

impdesigns [6:07 AM]
I’d love to see some sort of native, multi-environment support. I currently use EE Master Config from the Focus Lab guys (hoping they update that soon for 3.0)

       
TJ Draper's avatar
TJ Draper
222 posts
10 years ago
TJ Draper's avatar TJ Draper

For the record, environment detection is fairly easy with EE 3:

https://gist.github.com/tjdraper/d875ecd2809ae52e4254

This is using the same principles as the Focus Lab master config, but trying to keep things as native as possible by using the EE user config file.

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Yeah I like that TJ, it’s similar to what I use. This is partly an education issue, and partly providing a sensible default base.

One important security related issue for people using dynamic config, whether they use someone else’s solution or roll their own is to ensure that they either:

  1. aren’t using the HTTP_HOST header
  2. or are comparing it to a whitelist and falling back on a default if there is no match
       
TJ Draper's avatar
TJ Draper
222 posts
10 years ago
TJ Draper's avatar TJ Draper

I’m using HTTP_HOST in my gist. Do you have a recommendation for something else or to make what I have safer?

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

I’d use a whitelist like you are doing for SERVER_NAME.

       
TJ Draper's avatar
TJ Draper
222 posts
10 years ago
TJ Draper's avatar TJ Draper

That’s a good idea. I’ll get that updated tonight.

       
Sjoerd's avatar
Sjoerd
233 posts
10 years ago
Sjoerd's avatar Sjoerd

Looks good! But How to set different upload paths? The upload path for local (MAMP) and production differs…

       
TJ Draper's avatar
TJ Draper
222 posts
10 years ago
TJ Draper's avatar TJ Draper

Note on line 94 of config.php I’m requiring config.uploadPreferences.php.

Then in config.uploadPreferences.php I’m using the $uploadsPath variable which I have set dynamically earlier in the config to get to the right directory for your public directory. From there you set your path. Make sure to use the DIRECTORY_SEPERATOR constant if you want the config to work in any PHP/OS environment.

The URL can be set as a root-relative link as you see in the example.

       
Sjoerd's avatar
Sjoerd
233 posts
10 years ago
Sjoerd's avatar Sjoerd

Got it, thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.