Last active
October 12, 2017 07:52
-
-
Save jippi/c993b8ef4a6a3cd1765d to your computer and use it in GitHub Desktop.
CakePHP inside a Phar file. NOTE: Change "ROOT" constant in paths.php to "."
This file contains hidden or 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 | |
require 'vendor/autoload.php'; | |
$phar = new Phar(__DIR__ . '/dist/bownty-infra.phar', 0, 'bownty-infra'); | |
$phar->startBuffering(); | |
$collection = collection(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__))); | |
$collection = $collection->reject(function($file) { return $file->getFilename() === '.'; }); | |
$collection = $collection->reject(function($file) { return $file->getFilename() === '..'; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '.git') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/dist/') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/logs/') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/tmp/') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/tests/') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/test/') !== false; }); | |
$collection = $collection->reject(function($file) { return strpos($file->getPath(), '/webroot/') !== false; }); | |
$phar->buildFromIterator($collection, __DIR__); | |
$stub = "#!/usr/bin/env php \n" . $phar->createDefaultStub('bin/cake-phar.php'); | |
$phar->setStub($stub); | |
$phar->stopBuffering(); |
This file contains hidden or 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 | |
// only change to the file is removing line 1 from bin/cake.php | |
include dirname(__DIR__) . '/config/bootstrap.php'; | |
exit(Cake\Console\ShellDispatcher::run($argv)); |
This file contains hidden or 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
SHELL := /bin/bash | |
.PHONY: phar clean help | |
.DEFAULT_GOAL := help | |
phar: ## Build a phar file | |
mkdir -p dist/ | |
rm -f dist/bownty-infra.phar | |
php build.php | |
chmod 0775 dist/bownty-infra.phar | |
clean: ## Cleanup the dist/ directory | |
rm -rf dist/ | |
help: | |
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment