Last active
December 29, 2015 19:19
-
-
Save sharkpp/7716423 to your computer and use it in GitHub Desktop.
FuelPHP を Phar にまとめるためのスクリプト
This file contains 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 | |
/* | |
* Copyright (c) 2013 sharkpp | |
* This software is released under the MIT License. | |
* http://opensource.org/licenses/mit-license.php | |
*/ | |
// 確実に削除 | |
@unlink('index.phar'); | |
// phar書庫作成のためクラスを生成 | |
$phar = new Phar(__DIR__ . '/index.phar', 0, 'index.phar'); | |
// fuelphp17 ディレクトリ丸ごと固める | |
$phar->buildFromDirectory(__DIR__ . '/fuelphp-1.7/'); | |
// gzipで圧縮 | |
//$phar->compressFiles(Phar::GZ); // ※ css などがうまく取り出せない | |
// 起動スタブを設定 | |
$phar->setStub(<<<'EOD' | |
<?php | |
function phar_rewrites($path) { | |
if (0 === strpos($path,'/assets/')) | |
return '/public' . $path; // assets だけはパスを変更 | |
return '/public/index.php'.$path; // あとはすべてindexに渡す | |
} | |
Phar::interceptFileFuncs(); | |
Phar::webPhar('index.phar', 'public/index.php', '', array(), 'phar_rewrites'); | |
__HALT_COMPILER(); ?> | |
EOD | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment