Created
September 25, 2012 03:58
-
-
Save nise-nabe/3779900 to your computer and use it in GitHub Desktop.
phar test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = array('testdir/Foo.class.php', 'Hello.class.php'); | |
// pharインスタンスを生成 | |
$phar = new Phar(dirname(__FILE__) . '/test.phar', 0, 'test.phar'); | |
// ファイルをアーカイブに追加 | |
foreach ($files as $filename) | |
{ | |
$phar[$filename] = file_get_contents($filename); | |
} | |
echo "created\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public function getName() { | |
return __CLASS__; | |
} | |
public function execute() { | |
return 'This is ' . $this->getName(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hello | |
{ | |
public function getName() { | |
return __CLASS__; | |
} | |
public function greet() { | |
echo __FILE__; | |
return 'Hello, world!'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// pharに含まれるファイルを取り出す | |
require_once 'phar://test.phar/testdir/Foo.class.php'; | |
require_once 'phar://test.phar/Hello.class.php'; | |
$foo = new Foo(); | |
echo $foo->execute() . "\n"; | |
$greet = new Hello(); | |
echo $greet->greet() . "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public function getName() { | |
return __CLASS__; | |
} | |
public function execute() { | |
return 'This is ' . $this->getName(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment