Skip to content

Instantly share code, notes, and snippets.

@raphaeldealmeida
Created February 25, 2012 06:38
Show Gist options
  • Save raphaeldealmeida/1907026 to your computer and use it in GitHub Desktop.
Save raphaeldealmeida/1907026 to your computer and use it in GitHub Desktop.
Exemplo_phar
<?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');
}
}
<?php
include_once 'phar://Myapp.phar';
echo 'PHP Arquive: ' . MyApp\Date::next_week() . "\n";
<?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