Skip to content

Instantly share code, notes, and snippets.

@jlebensold
Created October 2, 2011 19:44
Show Gist options
  • Save jlebensold/1257841 to your computer and use it in GitHub Desktop.
Save jlebensold/1257841 to your computer and use it in GitHub Desktop.
Zendcasts: Fun with PHAR
<?php
include_once 'phar://Zendcasts.phar';
$str = new Zendcasts\Strings();
echo $str->reverseMe('Hello World'). "\n";
echo 'from PHAR: ' . Zendcasts\Dates::next_week() . "\n";
<?php
$phar = new Phar('Zendcasts.phar');
$phar->buildFromDirectory(dirname(__FILE__) . '/Zendcasts','/\.php$/');
$phar->compressFiles( Phar::GZ);
$phar->stopBuffering();
$phar->setStub($phar->createDefaultStub('Dates.php'));
<?php
namespace Zendcasts;
class Dates {
public static function next_week()
{
$datetime = new \DateTime();
$datetime->add(new \DateInterval('P7D'));
return $datetime->format('Y-m-d');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment