Skip to content
Permalink
Browse files

Fix phar build

  • Loading branch information...
greg-1-anderson committed Jan 2, 2019
1 parent d77d75d commit 718ad6931a3b3773f78d8316eba04ae056dfd25c
Showing with 18 additions and 1 deletion.
  1. +18 −1 robo
19 robo
@@ -4,11 +4,28 @@
* If we're running from phar load the phar autoload,
* else let the script 'robo' search for the autoloader.
*/
// Hack: \Phar::running() cannot be used reliably here to determine
// if we are running as a phar or not (works when phar is built with
// box, but does not work when phar is built with the Robo phar task.)
// We will use __FILE__ to determine our phar path; however, we cannot
// distinguish whether a __FILE__ of "/path/robo" is this file, or a
// 'robo.phar' that has been renamed to 'robo'. We will use the file
// size to differentiate.
// Recommendation: Use box to build your phar. See https://github.com/g1a/starter
$isPhar = (filesize(__FILE__) > 500000);
// Non-phar autoloader paths
$candidates = [
'phar://robo.phar/vendor/autoload.php', // phar path
__DIR__.'/vendor/autoload.php',
__DIR__.'/../../autoload.php',
];
// Use our phar alias path
if ($isPhar) {
array_unshift($candidates, 'phar://robo.phar/vendor/autoload.php');
}
$autoloaderPath = false;
foreach ($candidates as $candidate) {
if (file_exists($candidate)) {

0 comments on commit 718ad69

Please sign in to comment.
You can’t perform that action at this time.