-
Notifications
You must be signed in to change notification settings - Fork 0
/
makePHAR.php
36 lines (33 loc) · 1.24 KB
/
makePHAR.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
ini_set('default_charset', 'UTF-8');
date_default_timezone_set('america/costa_rica');
//readfile(__DIR__.'/phar_loader.php');
$phar_file=__DIR__.'/build/MRcore.phar';
if(ini_get('phar.readonly')){
throw new Exception("Se requiere phar.readonly=Off en php.ini para continuar.\n".php_ini_loaded_file());
}
echo "Eliminando archivos antiguos...".PHP_EOL;
if(file_exists($phar_file)) unlink($phar_file);
if(file_exists($phar_file.'.gz')) unlink($phar_file.'.gz');
echo "Creando nuevo archivo PHAR...".PHP_EOL;
$stub='<?php require "phar://".__FILE__."/loader.php"; __HALT_COMPILER();';
$metadata=[
'author'=>'Yordanny Mejías',
'email'=>'yordanny90@gmail.com',
'description'=>'MiniRouter Core',
'version'=>'0.2',
'update'=>date(DATE_W3C),
'repo'=>'https://github.com/yordanny90/MiniRouter',
'default_charset'=>ini_get('default_charset'),
];
$phar=new Phar($phar_file);
$phar->setStub($stub);
$phar->setMetadata($metadata);
$phar->buildFromDirectory(__DIR__.'/src');
//$phar->addFile(__DIR__.'/build/Help.md', 'Help.md');
echo "Comprimiendo archivo PHAR...".PHP_EOL;
$pharGZ=$phar->compress(Phar::GZ);
$pharGZ->setStub($stub);
print_r($pharGZ->getMetadata());
print_r($pharGZ->getSignature());
echo "Completado! ".(time()-$_SERVER['REQUEST_TIME']).'s';