PHP 클래스 YiiRequirementChecker, yii2

This class allows rendering of the check report for the web and console application interface. Example: php require_once('path/to/YiiRequirementChecker.php'); $requirementsChecker = new YiiRequirementChecker(); $requirements = array( array( 'name' => 'PHP Some Extension', 'mandatory' => true, 'condition' => extension_loaded('some_extension'), 'by' => 'Some application feature', 'memo' => 'PHP extension "some_extension" required', ), ); $requirementsChecker->checkYii()->check($requirements)->render(); If you wish to render the report with your own representation, use YiiRequirementChecker::getResult instead of YiiRequirementChecker::render Requirement condition could be in format "eval:PHP expression". In this case specified PHP expression will be evaluated in the context of this class instance. For example: php $requirements = array( array( 'name' => 'Upload max file size', 'condition' => 'eval:$this->checkUploadMaxFileSize("5M")', ), ); Note: this class definition does not match ordinary Yii style, because it should match PHP 4.3 and should not use features from newer PHP versions!
부터: 2.0
저자: Paul Klimov ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 메소드들

메소드 설명
check ( array | string $requirements ) Check the given requirements, collecting results into internal field.
checkPhpExtensionVersion ( string $extensionName, string $version, string $compare = '>=' ) : boolean Checks if the given PHP extension is available and its version matches the given one.
checkPhpIniOff ( string $name ) : boolean Checks if PHP configuration option (from php.ini) is off.
checkPhpIniOn ( string $name ) : boolean Checks if PHP configuration option (from php.ini) is on.
checkUploadMaxFileSize ( string | null $min = null, string | null $max = null ) : boolean Checks if upload max file size matches the given range.
checkYii ( ) : YiiRequirementChecker Performs the check for the Yii core requirements.
compareByteSize ( string $a, string $b, string $compare = '>=' ) : boolean Compare byte sizes of values given in the verbose representation, like '5M', '15K' etc.
evaluateExpression ( string $expression ) : mixed Evaluates a PHP expression under the context of this class.
getByteSize ( string $verboseSize ) : integer Gets the size in bytes from verbose size representation.
getNowDate ( ) : string Returns the now date if possible in string representation.
getResult ( ) : array | null Return the check results.
getServerInfo ( ) : string Returns the server information.
normalizeRequirement ( array $requirement, integer $requirementKey ) : array Normalizes requirement ensuring it has correct format.
render ( ) Renders the requirements check result.
renderViewFile ( string $_viewFile_, array $_data_ = null, boolean $_return_ = false ) : string Renders a view file.
usageError ( string $message ) Displays a usage error.

메소드 상세

check() 공개 메소드

This method can be invoked several times checking different requirement sets. Use YiiRequirementChecker::getResult or YiiRequirementChecker::render to get the results.
public check ( array | string $requirements )
$requirements array | string requirements to be checked. If an array, it is treated as the set of requirements; If a string, it is treated as the path of the file, which contains the requirements;

checkPhpExtensionVersion() 공개 메소드

Checks if the given PHP extension is available and its version matches the given one.
public checkPhpExtensionVersion ( string $extensionName, string $version, string $compare = '>=' ) : boolean
$extensionName string PHP extension name.
$version string required PHP extension version.
$compare string comparison operator, by default '>='
리턴 boolean if PHP extension version matches.

checkPhpIniOff() 공개 메소드

Checks if PHP configuration option (from php.ini) is off.
public checkPhpIniOff ( string $name ) : boolean
$name string configuration option name.
리턴 boolean option is off.

checkPhpIniOn() 공개 메소드

Checks if PHP configuration option (from php.ini) is on.
public checkPhpIniOn ( string $name ) : boolean
$name string configuration option name.
리턴 boolean option is on.

checkUploadMaxFileSize() 공개 메소드

Checks if upload max file size matches the given range.
public checkUploadMaxFileSize ( string | null $min = null, string | null $max = null ) : boolean
$min string | null verbose file size minimum required value, pass null to skip minimum check.
$max string | null verbose file size maximum required value, pass null to skip maximum check.
리턴 boolean success.

checkYii() 공개 메소드

Performs the check for the Yii core requirements.
public checkYii ( ) : YiiRequirementChecker
리턴 YiiRequirementChecker self instance.

compareByteSize() 공개 메소드

Compare byte sizes of values given in the verbose representation, like '5M', '15K' etc.
public compareByteSize ( string $a, string $b, string $compare = '>=' ) : boolean
$a string first value.
$b string second value.
$compare string comparison operator, by default '>='.
리턴 boolean comparison result.

evaluateExpression() 공개 메소드

Evaluates a PHP expression under the context of this class.
public evaluateExpression ( string $expression ) : mixed
$expression string a PHP expression to be evaluated.
리턴 mixed the expression result.

getByteSize() 공개 메소드

For example: '5K' => 5*1024
public getByteSize ( string $verboseSize ) : integer
$verboseSize string verbose size representation.
리턴 integer actual size in bytes.

getNowDate() 공개 메소드

Returns the now date if possible in string representation.
public getNowDate ( ) : string
리턴 string now date.

getResult() 공개 메소드

Return the check results.
public getResult ( ) : array | null
리턴 array | null check results in format: ```php array( 'summary' => array( 'total' => total number of checks, 'errors' => number of errors, 'warnings' => number of warnings, ), 'requirements' => array( array( ... 'error' => is there an error, 'warning' => is there a warning, ), ... ), ) ```

getServerInfo() 공개 메소드

Returns the server information.
public getServerInfo ( ) : string
리턴 string server information.

normalizeRequirement() 공개 메소드

Normalizes requirement ensuring it has correct format.
public normalizeRequirement ( array $requirement, integer $requirementKey ) : array
$requirement array raw requirement.
$requirementKey integer requirement key in the list.
리턴 array normalized requirement.

render() 공개 메소드

The output will vary depending is a script running from web or from console.
public render ( )

renderViewFile() 공개 메소드

This method includes the view file as a PHP script and captures the display result if required.
public renderViewFile ( string $_viewFile_, array $_data_ = null, boolean $_return_ = false ) : string
$_viewFile_ string view file
$_data_ array data to be extracted and made available to the view file
$_return_ boolean whether the rendering result should be returned as a string
리턴 string the rendering result. Null if the rendering result is not required.

usageError() 공개 메소드

This method will then terminate the execution of the current application.
public usageError ( string $message )
$message string the error message