Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bin/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public function __construct() {
'msg' => 'See https://github.com/kenjis/codeigniter3-filename-checker',
'example_branch' => 'master',
),

'twig' => array(
'site' => 'github',
'user' => 'kenjis',
'repos' => 'codeigniter-ss-twig',
'name' => 'CodeIgniter3 Simple and Secure Twig Integration',
'dir' => 'libraries',
'msg' => 'See https://github.com/kenjis/codeigniter-ss-twig',
'require' => array("twig/twig", "~1.22"),
),

'codeigniter-develbar' => array(
'site' => 'github',
'user' => 'jcsama',
Expand Down Expand Up @@ -144,6 +155,21 @@ public function install($package, $version)
$this->recursiveCopy($src, $dst);
$this->recursiveUnlink($this->tmp_dir);

// install package needed by this library (if any)
if (array_key_exists('require',$this->packages[$package])) {
$input = file_get_contents( __DIR__."/../composer.json");
$composer = json_decode($input);

$require = $this->packages[$package]['require'][0];
$composer->require->$require = $this->packages[$package]['require'][1];

$output = json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
copy(__DIR__."/../composer.json", __DIR__."/../composer.json.save");
file_put_contents(__DIR__."/../composer.json", $output);
echo 'Installing package: ' . $this->packages[$package]['name'] . PHP_EOL;
passthru('composer update');
}

$msg = 'Installed: ' . $package .PHP_EOL;
if (isset($this->packages[$package]['msg'])) {
$msg .= $this->packages[$package]['msg'] . PHP_EOL;
Expand Down