1

I'm trying to use OPENSHIFT environment variables in my Laravel 4 application, but it doesn't seem to work! I read the following question: Laravel 4 accessing environment variables But in OnpenShift I don't have access to server config.

I always used

$path = $_ENV['OPENSHIFT_DATA_DIR'] . 'uploads/thumbs/';

But $_ENV and getEnv() always returns me nothing.

How can I get that?

Community
  • 1
  • 1
wiLLiamcastrO
  • 238
  • 3
  • 13
  • `getenv('OPENSHIFT_DATA_DIR')` should work. If not, I think its not an Laravel problem. – JackPoint Jan 29 '14 at 13:38
  • It doesn't, but only with Laravel I got this problem, outside Laravel's folder it works properly, but I don't know, in some part the env vars are been cleaned. – wiLLiamcastrO Jan 29 '14 at 13:40

3 Answers3

2

You could try using the Laravel 4 quickstart https://www.openshift.com/quickstarts/laravel-4-on-openshift

niharvey
  • 2,807
  • 2
  • 15
  • 24
0

The PHP command is getenv('my_var_name'), which should work fine. See PHP Environment Variables in the OpenShift Developer Portal for more info.

luciddreamz
  • 2,073
  • 14
  • 15
0

I need to set fallback values. then I can keep my local settings. So I do this

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => getenv('OPENSHIFT_MYSQL_DB_HOST') ? getenv('OPENSHIFT_MYSQL_DB_HOST') :'127.0.0.1',
            'port'      => getenv('OPENSHIFT_MYSQL_DB_PORT') ? getenv('OPENSHIFT_MYSQL_DB_PORT') :'3306',
            'database'  => 'mydatabase',
            'username'  => 'admintest',
            'password'  => 'asd123asd',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),
Alupotha
  • 9,710
  • 4
  • 47
  • 48