Composer installation error - file is not within the allowed path

composer-php, symfony

Solution

Adjust `open_basedir` in your php.ini to include the path to your project and the other paths that composer tries to load from/write to. The variable accepts multiple paths separated by `:` (unix) or `;` (windows).

open_basedir = "/home/sites/yoursites/:/tmp/:/"

... or remove the restriction completely from php.ini.

; remove open_basedir completely ...
; <nothing here>

; ... comment it out like this ...
; open_basedir = "..." 

; ... or set it to an empty value like this ...
open_basedir = 

You can find the location of the correct php.ini for the CLI sapi with:

php --ini

Problem

I am trying to install composer on windows (symfony 2 project). The problem is that I always get some strage errors - that a couple of files are not in the allowed path. I've tried a couple of methods to install compsoer: - Downloading raw composer.phar file, throwing it into the symfony2 root folder and running composer installation command. It gives me an error that usr/.../composer/.htaccess is not within the allowed path - php -r "path" gives similar results as above, but with more "not in the allowed path" errors - Windows installer - it throws an error that the installer couldn't execute php.exe file, no idea why. What's wrong?

Original source