0

I have installed php and composer on a Windows Vista 64 machine. I am having a devil of a time getting Composer to accept a directive to use a specified directory other than the default C:\Users\\AppData\Roaming\Composer.

I tried to set up a config.json file viz:

{
    "config": {
        "COMPOSER_HOME": "c:\inetpub\wwwroot\PHPcomposer\",
        "COMPOSER_CACHE_DIR": "c:\inetpub\wwwroot\PHPcomposer\"
    }    
}

and this was completely ignored. even added cache-dir for fun.

I tried altering the composer.json viz:

{
    "require": {
        "symfony/validator":         "2.1.*",
        "doctrine/dbal":             "2.2.*",
        "monolog/monolog":           "dev-master",
        "jtreminio/test-extensions": "dev-master"
    },
    "minimum-stability": "dev",
    "config": {
        "COMPOSER_HOME": "c:/inetpub/wwwroot/PHPcomposer/",
        "cache-dir": "c:/inetpub/wwwroot/PHPcomposer/",
        "COMPOSER_CACHE_DIR": "c:/inetpub/wwwroot/PHPcomposer/"
    }    
}

and still I am getting an open_basedir restriction in effect message referring to

C:\Users\<user>\AppData\Roaming\Composer

I also did a iisreset, just in case iis was caching stuff.

So, any clues as to where I am going wrong. I know I can alter php.ini, but that to me is violating the security that php is offering. I would prefer to tell Composer to behave and do what I tell it to do.


Here is the command line I used and the result of it, the same error occurs regardless of any settings in config.phar or the "config" section in composer.phar. The php.ini has open_basedir = "C:\inetpub\wwwroot":

C:\inetpub\wwwroot\PHPcomposer>composer install

[ErrorException]
file_exists(): open_basedir restriction in effect. 
File(C:/Users/Stuart/AppData/Roaming/Composer/.htaccess) is not 
within the allowed path(s): (C:\inetpub\wwwroot)


 install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev]
 [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress]
 [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
user3230847
  • 11
  • 2
  • 4
  • State the error message you are getting when doing a plain, unconfigured composer run, please. When I try to reproduce the problem, and I see the same message, I know I'm on the right track. Also explain which commands you are using, i.e. copy&paste the command line. – Sven Jan 25 '14 at 13:30
  • 1
    In the end I gave up and disabled the php.ini setting for open_basedir . A bit of a cop out, but what's the point of flogging a dead horse? – user3230847 Jan 27 '14 at 23:47

1 Answers1

0

You need to Create a directory c:\pathTo\composer and download composer.phar into it from here

Then setup COMPOSER_HOME and COMPOSER_CACHE_DIR before running php, in a batch file:

composer.bat

@ECHO off
SET cwd=%cd%
PUSHD "c:\pathTo\php-5.4.28"
SET COMPOSER_HOME=c:\pathTo\composer
SET COMPOSER_CACHE_DIR=c:\pathTo\composer
"c:\pathTo\php-5.4.28\php.exe" -c "c:\pathTo\phpIniDir" -ddisable_functions="" -ddisable_classes="" -n "c:\pathTo\composer\composer.phar" --working-dir="%cwd%" %* 
POPD
idragosalex
  • 1,585
  • 1
  • 12
  • 8