/
build_phar
executable file
·58 lines (48 loc) · 1.3 KB
/
build_phar
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
$directories = array(
'assets',
'controllers',
'locales',
'providers',
'services',
'vendor/composer',
'vendor/doctrine',
'vendor/pimple',
'vendor/psr',
'vendor/silex',
'vendor/symfony',
'vendor/twig',
'views'
);
$banner = <<<BANNER
This is the Isotope eCommerce migration tool.
Copyright (c) 2014-2016 terminal42 gmbh
BANNER
;
/**
* Do not change from here
*/
// Redirect everything to index.php except for asset paths
$rewrite_function = "function rewrite_function(\$path) {
if (substr(\$path, 0, 7) === '/assets') {
return \$path;
}
return 'index.php';
}";
$finder = new Symfony\Component\Finder\Finder();
$finder->files()->ignoreVCS(true)->in($directories);
$stub = Phine\Phar\Stub::create()
->interceptFileFuncs()
->setShebang(null)
->setBanner($banner)
->selfExtracting()
->webPhar(null, 'index.php', null, array(), 'rewrite_function')
->getStub();
$stub = preg_replace('/(\*\/)/', '$1' . "\n\n" . $rewrite_function, $stub, 1);
$builder = Phine\Phar\Builder::create('isotope-migration.phar.php');
$builder->addFile('index.php');
$builder->addFile('vendor/autoload.php');
$builder->setStub($stub);
$builder->buildFromIterator($finder->getIterator(), '.');