Skip to content

howto - php composer - File(/etc/pki/tls/certs) is not within the allowed path(s) - on arch linux

Since a few days (or weeks?), I discovered the following issue on one of my Arch Linux system.
Whenever I try to use PHP's composer, I got the following issue:


[ErrorException]
is_dir(): open_basedir restriction in effect. File(/etc/pki/tls/certs) is not within the allowed path(s): (/srv/http/ [...]

Well, it didn't hurt that much since I am using (like every cool webkiddy is doing) docker or vagrant for my development. But this time, I needed to solve it since it is a customer edge case - so I solved it.
The how to I will show you is not the perfect way. I had two things in mind, try to minimize the place I have to adapt the php.ini. And try to keep the system as normal as possible. Until now, I can not estimate the security holes I opened with this setting. I will let you know if this how to turns out to be a "don't try this at home" thing.

So, what have I done?
First of all, I asked curl to tell me where it is looking for certificates by executing:


curl-config --ca
#output: /etc/ssl/certs/ca-certificates.crt

After that I had a look what this path is:

ls -halt /etc/ssl/certs/ca-certificates.crt
#output: [...] /etc/ssl/certs/ca-certificates.crt -> ../../ca-certificates/extracted/tls-ca-bundle.pem

So, with that knowledge it turned out that the following steps are reflecting my requirements mention above.

sudo mkdir -p /etc/pki/tls/certs
sudo ln -s /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-certificates.crt
sudo vi /etc/php/php.ini
#add following lines to "open_basedir" configuration section
# :/etc/pki/tls/certs:/etc/ssl/certs

And that is it, composer should now be back in business.

gosh, why is my vendor directory consuming so much diskspace?

"Saving disk space on your composer projects" was a headline for an older entry I made.
I used this project and figured out it has a lot of bugs because of its "outdateness". Thats why I spend some time to create a build script, build a new "compify.phar" and created a pull request to it. Sadly, no response or action has been done by carlos (also no response on any e-mail).
I did the pull request on 28.07.2015, meaning a lot of water is gone down the river since then.
After waiting and waiting, I gave up and simple added my created "compify.phar" in a project called php project maintenance. As given by the name, this project has to goal to easy up maintenance for php projects ;-).
The, currently, best script inside is update_all_repositories which simple tries to find all git repositories from your current working directory. Inside each directory, it is doing some git stuff and also - since today - using compify to clean up the vendor diskspace. If you want to automate that kind of process, feel free to use it and pull some requests if there is something that can be optimized.

Saving disk space on your composer projects

Have you ever did a "du -sh" on your vendor folder and became shocked because of the size?
As example, if you require the zend framework 2 in your project, you have to download and store over 170 MB in your disk. Hopefully, you don't think this is the size of the framework.
And you are right, over 150 MB of the size is inside the ".git" folder. That is "nice to know" information if you are a zend framework 2 developer, but if you simple use it, you don't need it.
Thanks to carlos buenos vinos, all you need to do is to download a tool called compify. Once setted up on your machine, you only have to change into your project root and execute "compify crush vendor/".
You can automate that call by binding it with the "composer update" call, either via shell alias, shell script, ant target or phing target (or are you using maven for a php project?).

Convert VCF File into a CSV File

I needed to convert a VCF file into a CSV file by fetching the important and readable informations.
Thanks to the bazzline component it was a quick win/no brainer. You can find the result here. It is written under GPL-3 License.

How to use it?

  • open a terminal / command line
  • git clone https://github.com/stevleibelt/incubator
  • cd incubator/general/vcf_to_csv_converter
  • ./converter