Phar::setDefaultStub

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)

Phar::setDefaultStub — PHP 로더 또는 Phar 아카이브의 부트스트랩 스텁을 기본 로더로 설정하는 데 사용됩니다.


설명

public Phar::setDefaultStub(?string $index = null, ?string $webIndex = null): bool

메모: 이 메소드는 Phar 객체에 대해 작동하기 위해 php.ini 설정 phar.readonly0으로 설정해야 합니다. 그렇지 않으면 PharException이 발생합니다.

이 메소드는 Phar::createDefaultStub()Phar::setStub()의 기능을 결합한 편리한 메소드입니다.


매개변수

index
명령줄에서 액세스하는 경우 실행할 phar 아카이브 내의 상대 경로
webIndex
웹 브라우저를 통해 액세스하는 경우 실행할 phar 아카이브 내의 상대 경로

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


오류/예외

php.ini에서 phar.readonly가 활성화된 경우 UnexpectedValueException이 발생합니다. 디스크에 변경 사항을 플러시하는 데 문제가 발생하면 PharException이 발생합니다.


변경 로그

버전 설명
8.0.0 webIndex는 이제 null을 허용합니다.

Examples

예제 #1 Phar::setDefaultStub() 예제

                  
<?php
try {
    $phar = new Phar('myphar.phar');
    $phar->setDefaultStub('cli.php', 'web/index.php');
    // this is the same as:
    // $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php'));
} catch (Exception $e) {
    // handle errors
}
?>
                  
                

기타