2014-11-18 3 views
1

php phar 파일 관리에 대한 설명이 문서화 된대로 필요합니다. 예상 한 내용을 찾지 못했습니다.phar 파일에 대한 설명

나는 그런 스크립트와의 Phar 파일을 작성했습니다 그런 다음이

[main.php] 
<? 
include_once("./helloworld.php"); 
helloworld(); 
?> 

[helloworld.php] 
<? 
function helloworld() { 
    echo "Hello World\n"; 
} 
?> 

같은 간단한 프로젝트가 깊은에서 더 많은 : 나는 다른 [buildphar.php] 배포하는 경우

[buildphar.php] 
<? 
$pharfile = '/home/stefano/test.phar'; 
if (file_exists($pharfile)) unlink($pharfile); 
$phar = new Phar(
    $pharfile, 
    FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, 
    "test.phar" 
); 
$phar->startBuffering(); 
$phar['main.php'] = php_strip_whitespace("main.php"); 
$phar['helloworld.php'] = php_strip_whitespace("helloworls.php"); 
$phar->setStub($phar->createDefaultStub("main")); 
$phar->stopBuffering(); 

을 컴퓨터를 실행 해 봅니다.

php buildphar.php 

오류가 발생했습니다. "치명적 오류 : 'helloworld'not f ouch in phar : // (...) "따라서 질문은 다음과 같습니다. - include_once ('helloword.php')를 어떻게 유지할 수 있습니까? phar 파일에 phar 파일에 임베디드되어 있으므로 필요하지 않습니다. 포함시킬 것인가? - 내 접근 방식에있어 문제가 있습니까?

감사합니다. 스테파노

답변

1

코드는 작동하지 않습니다. 또한 buildphar.php을 배포하는 것이 의미가 없습니다. .phar 파일을 배포하는 것이 좋습니다.

phar stub에서 Phar::interceptFileFuncs()으로 직면하는 문제 (작동하지 않는 것을 포함하여)를 해결할 수 있습니다.