added installer script
parent
0a4f36ea6d
commit
dca0cbc93a
|
@ -10,7 +10,10 @@ See the [about page](http://packagist.org/about) on [packagist.org](http://packa
|
||||||
Installation / Usage
|
Installation / Usage
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
1. Download the [`composer.phar`](http://getcomposer.org/composer.phar) executable
|
1. Download the [`composer.phar`](http://getcomposer.org/composer.phar) executable or use the installer.
|
||||||
|
|
||||||
|
$ curl http://getcomposer.org/installer | php
|
||||||
|
|
||||||
2. Create a composer.json defining your dependencies. Note that this example is
|
2. Create a composer.json defining your dependencies. Note that this example is
|
||||||
a short version for applications that are not meant to be published as packages
|
a short version for applications that are not meant to be published as packages
|
||||||
themselves. To create libraries/packages please read the [guidelines](http://packagist.org/about).
|
themselves. To create libraries/packages please read the [guidelines](http://packagist.org/about).
|
||||||
|
@ -43,7 +46,7 @@ Since composer works with the current working directory it is possible to instal
|
||||||
in a system wide way.
|
in a system wide way.
|
||||||
|
|
||||||
1. Change into a directory in your path like `cd /usr/local/bin`
|
1. Change into a directory in your path like `cd /usr/local/bin`
|
||||||
2. Get composer `wget http://getcomposer.org/composer.phar`
|
2. Get composer `curl http://getcomposer.org/installer | php`
|
||||||
3. Make the phar executeable `chmod a+x composer.phar`
|
3. Make the phar executeable `chmod a+x composer.phar`
|
||||||
3. Change into a project directory `cd /path/to/my/project`
|
3. Change into a project directory `cd /path/to/my/project`
|
||||||
4. Use composer as you normally would `composer.phar install`
|
4. Use composer as you normally would `composer.phar install`
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
process($argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* processes the installer
|
||||||
|
*/
|
||||||
|
function process($argv)
|
||||||
|
{
|
||||||
|
$check = in_array('--check', $argv);
|
||||||
|
$help = in_array('--help', $argv);
|
||||||
|
$force = in_array('--force', $argv);
|
||||||
|
|
||||||
|
if ($help) {
|
||||||
|
displayHelp();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ok = checkPlatform();
|
||||||
|
|
||||||
|
if ($check && !$ok) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ok || $force) {
|
||||||
|
installComposer();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displays the help
|
||||||
|
*/
|
||||||
|
function displayHelp()
|
||||||
|
{
|
||||||
|
echo <<<EOF
|
||||||
|
Composer Installer
|
||||||
|
------------------
|
||||||
|
Options
|
||||||
|
--help this help
|
||||||
|
--check for checking environment only
|
||||||
|
--force forces the installation
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check the platform for possible issues on running composer
|
||||||
|
*/
|
||||||
|
function checkPlatform()
|
||||||
|
{
|
||||||
|
$errors = array();
|
||||||
|
if (false !== ini_get('detect_unicode')) {
|
||||||
|
$errors['unicode'] = 'On';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ini_get('phar.readonly')) {
|
||||||
|
$errors['readonly'] = 'On';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ini_get('phar.require_hash')) {
|
||||||
|
$errors['require_hash'] = 'On';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($suhosin = ini_get('suhosin.executor.include.whitelist') && (isset($suhosin) && false === stripos($suhosin, 'phar'))) {
|
||||||
|
$errors['suhosin'] = $suhosin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PHP_VERSION < '5.3.2') {
|
||||||
|
$errors['php'] = PHP_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($errors)) {
|
||||||
|
out("Composer detected that you have enabled some settings in your `php.ini` file that can make Composer unable to work properly.".PHP_EOL, 'error');
|
||||||
|
|
||||||
|
echo PHP_EOL.'Make sure that you have changed options listed below:'.PHP_EOL;
|
||||||
|
foreach ($errors as $error => $actual) {
|
||||||
|
switch ($error) {
|
||||||
|
case 'unicode':
|
||||||
|
$text = " detect_unicode = Off (actual: {$actual})".PHP_EOL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'readonly':
|
||||||
|
$text = " phar.readonly = Off (actual: {$actual})".PHP_EOL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'require_hash':
|
||||||
|
$text = " phar.require_hash = Off (actual: {$actual})".PHP_EOL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'suhosin':
|
||||||
|
$text = " suhosin.executor.include.whitelist = phar (actual: {$actual})".PHP_EOL;
|
||||||
|
break;
|
||||||
|
case 'php':
|
||||||
|
$text = " PHP_VERSION (actual: {$actual})".PHP_EOL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
out($text, 'info');
|
||||||
|
}
|
||||||
|
echo PHP_EOL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
out("All settings correct for using Composer".PHP_EOL,'success');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* installs composer to the current working directory
|
||||||
|
*/
|
||||||
|
function installComposer()
|
||||||
|
{
|
||||||
|
$installDir = getcwd();
|
||||||
|
$file = $installDir . DIRECTORY_SEPARATOR . 'composer.phar';
|
||||||
|
|
||||||
|
if (is_readable($file)) {
|
||||||
|
@unlink($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$download = copy('http://getcomposer.org/composer.phar', $installDir.DIRECTORY_SEPARATOR.'composer.phar');
|
||||||
|
|
||||||
|
out(PHP_EOL."Composer successfully installed to: " . $file, 'success');
|
||||||
|
out(PHP_EOL."Use it: php composer.phar".PHP_EOL, 'info');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* colorize output
|
||||||
|
*/
|
||||||
|
function out($text, $color = null)
|
||||||
|
{
|
||||||
|
$styles = array(
|
||||||
|
'success' => "\033[0;32m%s\033[0m",
|
||||||
|
'error' => "\033[31;31m%s\033[0m",
|
||||||
|
'info' => "\033[33;33m%s\033[0m"
|
||||||
|
);
|
||||||
|
|
||||||
|
echo sprintf(isset($styles[$color]) ? $styles[$color] : "%s", $text);
|
||||||
|
}
|
Loading…
Reference in New Issue