Overview

Namespaces

  • None
  • PHP
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class
  • Tree

Class Env

A service to detect the environment name and load configuration by environment name

The environment name detect order: user defined $name > $detector callback > $ipMap

Wei\Base
Extended by Wei\Env
Namespace: Wei
Author: Twin Huang twinhuang@qq.com
Located at Env.php
Methods summary
public
# __construct( array $options = array() )

Constructor

Constructor

Parameters

$options

Throws

InvalidArgumentException
When option "wei" is not an instance of "Wei\Wei"

Overrides

Wei\Base::__construct()
public string
# __invoke( )

Returns the environment name

Returns the environment name

Returns

string
public
# detectEnvName( )

Detect environment by server IP

Detect environment by server IP

public boolean
# is( string $env )

Check if in specified environment

Check if in specified environment

Parameters

$env

Returns

boolean
public boolean
# isDev( )

Check if in the development environment

Check if in the development environment

Returns

boolean
public boolean
# isTest( )

Check if is the test environment

Check if is the test environment

Returns

boolean
public boolean
# isProd( )

Check if in the production environment

Check if in the production environment

Returns

boolean
public string
# getName( )

Returns the env string

Returns the env string

Returns

string
public mixed
# setName( string $name )

Set application environment name

Set application environment name

Parameters

$name

Returns

mixed
$this
public mixed
# loadConfigFile( string $file, string $env = null )

Loads configs from specified file to service container

Loads configs from specified file to service container

Parameters

$file
The config file path
$env
The value to replace the %env% placeholder, default to the env name

Returns

mixed
$this
protected array
# getServerIps( )

Returns server IPs from ifconfig command line

Returns server IPs from ifconfig command line

Returns

array
Methods inherited from Wei\Base
__call(), __get(), getOption(), setOption()
Properties summary
protected string $name

The environment name

The environment name

#
protected callable $detector

A callback to detect the environment name

A callback to detect the environment name

#
protected array $ipMap

An associative array contains server ip and environment name pairs

An associative array contains server ip and environment name pairs

# array( '127.0.0.1' => 'dev' )
protected string $configFile

The configuration file pattern

The configuration file pattern

# 'config/config-%env%.php'
protected array $server

The server and execution environment parameters, equals to $_SERVER on default

The server and execution environment parameters, equals to $_SERVER on default

#
Properties inherited from Wei\Base
$providers, $wei
Wei Framework API documentation generated by ApiGen