Getting PHP composer to work with XAMPP on Arch Linux behind a corporate proxy (goal: install Laravel)

3/ 6/2015 | Comments: 2

It took me quite some tests until I finally found a way to get all those things working together:

  • Arch Linux
  • XAMPP
  • PHP
  • Composer
  • Laravel (PHP framework)
  • behind corporate proxy server (Squid)

So, in a nutshell, the necessary actions were:

Arch Linux

I'm working on an updated Arch Linux with no PHP, Apache, Composer whatsoever installed by means of Pacman as my goal is to run everything out of the XAMPP box.

Corporate proxy server

I have exported the variables http_proxy and https_proxy as I'm captured behind a proxy server on my work:

export http_proxy=<proxy-ip>:<proxy-port>
export https_proxy=<proxy-ip>:<proxy-port>

So no protocol prefixes for me (http://, https://), simply the plain IP addresses and port numbers.

XAMPP

Download and install XAMPP for Linux:

https://www.apachefriends.org/download.html

Usually, this will reside under /opt/lampp after this.

cert.pem

Strangely, there was no cert.pem to be found in my /opt/lampp/share/openssl/ directory, even though this ought to be the case, according to

php -r "print_r(openssl_get_cert_locations());"

So I downloaded this certificate file manually from http://curl.haxx.se/ca/cacert.pem and saved it in this directory under the name "cert.pem".

Environment variable HTTPS_PROXY_REQUEST_FULLURI

I read a lot about these two environment variables:

HTTP_PROXY_REQUEST_FULLURI=false
HTTPS_PROXY_REQUEST_FULLURI=false

But I definitely had to unset / delete them to prevent errors.

PHP

In order to find the PHP executable on the system, I appended "/opt/lampp/bin" to the exported PATH variable. I did this globally in /etc/profile.

Composer

Composer can be downloaded and installed into the XAMPP bin directory like so:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/opt/lampp/bin --filename=composer

As this bin directory is already visible through the PATH variable, PHP and composer are now directly accessible from the command line.

Composer, Laravel and the tricky part

Officially, Laravel can be installed with this command:

composer create-project laravel/laravel --prefer-dist

To get a very verbose output, you can add the option "-vvv" after the composer command. At first, I had an awful lot of problems with this step. But having found out and done all the previous steps at last, I was able to download Laravel.


Comments

Otto   4/16/2015

Same scenario as yours, fully solved thanks to your research.

composer_noob   6/29/2015

Thank you ! I could not update composer because of an openssl error. Your explanations about the cert.pem file allowed me to solve the problem quickly.

Leave Comment