-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some update, add a built-in controller for pack phar
- Loading branch information
Showing
16 changed files
with
502 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ composer.lock | |
*.swp | ||
*.swo | ||
*.zip | ||
*.phar | ||
.DS_Store | ||
.interactive_history |
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: inhere | ||
* Date: 2017-10-27 | ||
* Time: 10:02 | ||
*/ | ||
|
||
$srcDir = dirname(__DIR__, 2); | ||
$pharFile = $srcDir . '/project.phar'; | ||
//var_dump($srcDir);die; | ||
|
||
// create with alias "project.phar" | ||
$phar = new Phar($pharFile, 0, basename($pharFile)); | ||
$phar->setSignatureAlgorithm(Phar::SHA1); | ||
|
||
// 开始打包 | ||
$phar->startBuffering(); | ||
|
||
// add all files in the project, only include php files | ||
$phar->buildFromDirectory($srcDir, '/[\.php|app]$/'); | ||
$phar->setStub($phar::createDefaultStub('examples/app')); | ||
//$phar->setStub($phar::createDefaultStub('examples/app', 'www/index.php')); | ||
|
||
$phar->stopBuffering(); | ||
|
||
// 打包完成 | ||
echo "Finished {$pharFile}\n"; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: inhere | ||
* Date: 2017-10-27 | ||
* Time: 9:08 | ||
*/ | ||
|
||
namespace Inhere\Console\BuiltIn; | ||
|
||
use Inhere\Console\Controller; | ||
use Inhere\Console\Utils\PharCompiler; | ||
|
||
/** | ||
* Class PharController | ||
* @package Inhere\Console\BuiltIn | ||
*/ | ||
class PharController extends Controller | ||
{ | ||
protected static $name = 'phar'; | ||
protected static $description = 'provide package code to phar/unpack phar tool.'; | ||
|
||
/** | ||
* pack directory(s) to a phar file. | ||
* @arguments | ||
* src-dir The source directory for pack<red>*</red> | ||
* phar The output phar file path | ||
* | ||
* @options | ||
* -c,--compress Want compress php file. | ||
* --file-include Append file include | ||
* | ||
*/ | ||
public function packCommand() | ||
{ | ||
$pcr = new PharCompiler(BASE_PATH); | ||
$pcr->setOptions([ | ||
'cliIndex' => 'examples/app', | ||
'webIndex' => null, | ||
|
||
'compress' => $this->getSameOpt(['c', 'compress'], false), | ||
|
||
'dirExclude' => '#[\.git|tests]#', | ||
|
||
'fileInclude' => ['LICENSE', 'app', 'liteApp'], | ||
'fileMatch' => '#\.php#', | ||
]); | ||
|
||
$pharFile = BASE_PATH . '/test.phar'; | ||
$count = $pcr->pack($pharFile); | ||
|
||
$this->output->json([ | ||
'count' => $count, | ||
'size' => round(filesize($pharFile) / 1000, 2) . ' kb', | ||
]); | ||
} | ||
} |
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
File renamed without changes.
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
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
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
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
Oops, something went wrong.