2

I’m creating a deployment configuration for Laravel project. On my hosting public/ folder must be moved to another place. Obviously, since that, I need to change path to the autoload.php and app.php in index.php.

However, I’d like to add and use a parameter which would tell where these files reside. Something like this:

require __DIR__ . '/../' . env('DEP_EXT_FOLDER') . 'vendor/autoload.php';

I think, the most proper place for such a parameter is .env file. However, I’ve got an error:

Call to undefined function env() 
miken32
  • 42,008
  • 16
  • 111
  • 154
zhekaus
  • 3,126
  • 6
  • 23
  • 46
  • @lagbox , yes, I see, of course, you are right – zhekaus Dec 08 '17 at 15:01
  • 3
    that `env` function comes from one of the libraries that the autoloader is responsible for loading ... i would look at a different method :) – lagbox Dec 08 '17 at 15:02

1 Answers1

0

You can't use the env() function before loading the autoloader.

if you absolutely want to use your .env file, you will have to use native php preg_match() for finding your key and using the value after that :)

Mathieu Ferre
  • 4,246
  • 1
  • 14
  • 31