Introducing Webfat "Scope/d" - FRDL_HOME

The environment variable “FRDL_HOME” defines the global root directory of the frdl-context (the directory where the apps global scope lives in, different to the public www webdirectory).

You can now customize the scope by the init method or the environment variable “IO4_WORKSPACE_SCOPE”.

IO4_WORKSPACE_SCOPE can have the values

  • @cwd - current working directory - getcwd()
  •  @www -   public www web directory - $_SERVER['DOCUMENT_ROOT']
  • @global - USER HOME (Users HOME of current process or webspace) - the first directory in the cwd path wich is readable and writable by the current PHP process.
  • @www@parent - the superior directory of  $_SERVER['DOCUMENT_ROOT']
  • @www@root' -  the first directory in the $_SERVER['DOCUMENT_ROOT'] path wich is readable and writable by the current PHP process.
  • custom directory - set a path/directory in IO4_WORKSPACE_SCOPE

Code from Webfat:

if(null === $scope){
 $scope = !empty(getenv('IO4_WORKSPACE_SCOPE')) ? getenv('IO4_WORKSPACE_SCOPE') : null;
}
    
switch($scope){
    case '@cwd' :
           $__home =  getcwd();
     break;        
    case '@www' :
           $__home =  $_SERVER['DOCUMENT_ROOT'];
     break;    
    case '@www@root' :
           $__home =  $getRootDir($_SERVER['DOCUMENT_ROOT']);
     break;    
    case '@www@parent' :
           $__home =  dirname($_SERVER['DOCUMENT_ROOT']);
     break;    
    case '@global' :
    case null :
           $__home = $HOME_DEFAULT;
      break;
    default :
          $__home = is_dir(getenv('IO4_WORKSPACE_SCOPE')) ? getenv('IO4_WORKSPACE_SCOPE') : $HOME_DEFAULT;
     break;
}
 

$__home = @is_readable($__home) && @is_writable($__home) ? $__home : $getRootDir($_SERVER['DOCUMENT_ROOT']);

$_ENV['FRDL_HOME'] = $__home;    
putenv('FRDL_HOME='.$_ENV['FRDL_HOME']);

Comments

NoticeLog in

Your need to be logged in to be able to comment.

connect with ❤️Webfan | connect with Google