Created
February 25, 2012 06:38
-
-
Save raphaeldealmeida/1907026 to your computer and use it in GitHub Desktop.
Exemplo_phar
This file contains hidden or 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 | |
//colocar na pasta app | |
namespace MyApp; | |
class Date { | |
public static function next_week() | |
{ | |
$datetime = new \DateTime(); | |
$datetime->add(new \DateInterval('P7D')); | |
return $datetime->format('Y-m-d'); | |
} | |
} |
This file contains hidden or 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 | |
include_once 'phar://Myapp.phar'; | |
echo 'PHP Arquive: ' . MyApp\Date::next_week() . "\n"; |
This file contains hidden or 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 | |
//Cria o arquivo phar | |
$phar = new Phar('Myapp.phar'); | |
//adiciona pastas ao "include_path" | |
$phar->buildFromDirectory(dirname(__FILE__) . '/app','/\.php$/'); | |
//compacta | |
$phar->compressFiles( Phar::GZ); | |
$phar->stopBuffering(); | |
//paremetro raiz | |
$phar->setStub($phar->createDefaultStub('Dates.php')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment