Skip to content

Instantly share code, notes, and snippets.

@sharkpp
Last active December 29, 2015 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharkpp/7716423 to your computer and use it in GitHub Desktop.
Save sharkpp/7716423 to your computer and use it in GitHub Desktop.
FuelPHP を Phar にまとめるためのスクリプト
<?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