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.

Translate to de es fr it pt ja

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 updateallrepositories 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.

Translate to de es fr it pt ja

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?).

Translate to de es fr it pt ja

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/vcftocsv_converter
  • ./converter
Translate to de es fr it pt ja

version 1.0.1 of process pipeline component for php released

I happy to announce the release of 1.0.1 of bazzlines process pipeline component for php. Important changes are:

  • removed dependecy to apigen
  • add "StopExecutionException"
Translate to de es fr it pt ja

version 1.0.3 of command component for php released

I am happy to announce the release of 1.0.3 of bazzlines command component for php. This component will easy up the usage of system commands.
Major improvement is the public method "validateSystemEnvironment". You should use this (maybe in your factory) to validate if the system environment is valid (e.g. "/usr/bin/ls" exists and is executable). An exception should be thrown, so you can easily track back the source of the validation error.
Enjoy it.

Translate to de es fr it pt ja

version 1.0.2 of command component for php released

I am happy to announce the release of 1.0.2 of bazzlines command component for php. This component will easy up the usage of system commands.
Indeed, I missed to announce 1.0.0, but you know, christmas is hard time and this component is really a small one.
This project aims to deliver a easy to use php command component. It adds a very thin layer but hopefully adds a lot of usage and handling benefits :-).

Usage


usage Net\Bazzline\Component\Command\Command;

class Zip extends Command { /** * @param string $archiveName * @param array $items * @return array * @throws RuntimeException * @todo implement parameter validation */ public function zip($archiveName, array $items) {
$command = '/usr/bin/zip -r ' . $archiveName . ' ' . implode(' ' , $items);

    return $this->execute($command);
}

/** 
 * @param string $pathToArchive
 * @param null|string $outputPath
 * @return array
 * @throws RuntimeException
 * @todo implement parameter validation
 */
public function unzip($pathToArchive, $outputPath = null)
{   
    if (!is_null($outputPath)) {
        $command = '/usr/bin/unzip ' . $pathToArchive . ' -d ' . $outputPath;
    } else {
        $command = '/usr/bin/unzip ' . $pathToArchive;
    }

    return $this->execute($command);
}

/** 
 * @param string $pathToArchive
 * @return array
 * @throws RuntimeException
 * @todo implement parameter validation
 */
public function listContent($pathToArchive)
{   
    $command = '/usr/bin/unzip -l ' . $pathToArchive;

    return $this->execute($command);
}

}

$zip = new Zip();

$pathToZipArchive = '/tmp/my.zip';

echo 'list archive content' . PHPEOL; $lines = $zip->listContent($pathToZipArchive); foreach ($lines as $line) { echo $line . PHPEOL; }

echo 'unzip archive' . PHPEOL; $zip->unzip($pathToZipArchive, '/tmp/mydirectory');

echo 'zip directory' . PHPEOL; $zip->zip($pathToZipArchive, array('/tmp/mydirectory'));

How to install?

By Hand


mkdir -p vendor/netbazzline/phpcomponentcommand
cd vendor/netbazzline/phpcomponentcommand
git clone https://github.com/bazzline/phpcomponentcommand .

With Packagist


composer require netbazzline/phpcomponent_command:dev-master
Translate to de es fr it pt ja

php composer - "requires ext-iconv * -> the requested PHP extension iconv is missing from your system."

It took me some minutes to figure this out. First I checked my "php.ini" in "/etc/php". Then, I checked it multiple times and the error is not gone. Afterwards, a browsing on the web pointed me the glowing path in the dark ;-).
First you have to know is the fact, that composer is having its own "php.ini". It is stored in "/usr/share/php-composer/php.ini". All you have to do is to add "extension=iconv.so" in the "[PHP]" section and thats it. Happy composing :-)

Translate to de es fr it pt ja

version 1.0.0 of process pipeline component for php released

I happy to announce the release of 1.0.0 of bazzlines process pipeline component for php. This component will easy up the creation of process pipe.

Indeed, it is a pseudo pipeline (process collection or process batch) since the php process is single threaded so far.

Special thanks to Ralf Westphal and especially for his book the architects napkin.

Why?

  • separate complex operations into simpler
  • easy up unit testing for smaller processes
  • separate responsibility (data generator/transformer/validator/flow manipulator)
  • create process chains you can read in the code (separate integration code from operation code)
  • no dependencies (except you want to join the development team)

How to use?


use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try { $pipe = new Pipe();

$pipe->pipe(
    new ProcessOne(), 
    new ProcessTwo()
);

$output = $pipe->execute($input);

} catch (ExecutableException) { //handle process exception } catch (InvalidArgumentException) { //handle pipe exception }

How to install?

By Hand


mkdir -p vendor/netbazzline/phpcomponentprocesspipe
cd vendor/netbazzline/phpcomponentprocesspipe
git clone https://github.com/bazzline/phpcomponentprocesspipe

With Packagist


composer require netbazzline/phpcomponentprocess_pipe:dev-master
Translate to de es fr it pt ja

PHP Component - Data Type

By using this component, you are able to use type hints also for basic data types.
This component includes class definitions for php basic data types like:

  • Boolean
  • Floating point
  • Integer
  • String
  • Numeric

Features

  • Enables type hints for basic php types
  • Types shipped with useful methods
  • Are comparable with native php types by using "=="
  • Provides generic type casting by implemented "toString()" methods (and so on)

Usage

Example


/**
 * Class with type hint for string
 *
 * @author stev leibelt 
 * @since 2013-08-04
 */
class MyClass
{
    /**
     * @var array
     * @author stev leibelt 
     * @since 2013-08-04
     */
    private $strings = array();

    /**
     * Super cool method with type hint for string
     *
     * @author stev leibelt 
     * @since 2013-08-04
     */
    public function addString(\Net\Bazzline\Component\DataType\String $string)
    {
        $this->strings[] = $string;

        return $this;
    }
}

$myString = new \Net\Bazzline\Component\DataType\String('super cool test string');

$myClass = new MyClass();
$myClass->addString($myString);

Hints

  • Extend provided types with classes in own namespace.
  • If you add a super cool method to your type, push it and be a part of the development team

Install

Via Git


cd path/to/my/git/respositories
mkdir -p stevleibelt/php_component_data_type
cd stevleibelt/php_component_data_type

git clone git://github.com/stevleibelt/php_component_data_type.git .

Via Composer


require: "net_bazzline/component_data_type": "dev-master"

Why?

I started developing this component because of the many casts i have to do while dealing with php's basic data types. As general, i searched the web for existing and easy to use components but could not find them. If you find one, please tell me. Last but not least SplTypes are still experimental.

Translate to de es fr it pt ja

PHP Component TestCase

I've finished writing unit tests for this component a few minutes ago so as the a beloved meme would say "things are getting pretty serious" ;-). It is possible i will tag the version "1.0.0" very soon.

What is this component for and where do i get it?
This component is considered as a starting point for creating question and answer test cases. Each test case has one question and one answer type. The current available types of answers are "single answer", "multiple answer" and "free text answer". All three types are using the same interface, so you can use them everywhere. You have to enter an answer to an answer (quite surprising right? ;-)) and the answer has the ability to tell you if your answer was the right one or how correct your current answer is.
The ideal wish is, that a lot of people are writing test cases for different subjects and you just simple use this component and the subjects to create your application or environment to use this test cases to, well, test people or yourself.
You can get the TestCase on github.com or via packagist.

A suite is also there to arrange multiple test cases under one subject. Since this component is using the Configuration Converter, everything can be written down as "YAML", "JSON" or "PHPArray". To illustrate this, you can write a "Suite.yaml" that points to a "TestCase.php" that is using a "Question.php" and a "Answer.yaml". The available factories can handle that if you want to.

The component itself is currently really basic so do not expect that finished "save the world" thing. But the test case stuff is started and truly open source.

Translate to de es fr it pt ja

PHPUGHH130611 - composer introduction and MySql Database Clustering

Where

Mindworks Jarrestraße 42A Hamburg

InnoGames Game Jam - By Frank Sons

  • 48 hours to develop a game
  • Can work alone or in pair
  • Free food and drinks
  • From 21 June to 23

Game Jam

So Coded - A Web Conference In Hamburg - By Ole Michaelis

  • A lot of cities currently have conference
  • Hamburg also should have one
  • A lot of speakers from hamburg (and germany also ;-))
  • Its not only for java script or php guys
  • 19 - 20 of September 2013

so coded

Introduction To Composer - By Till Klampäckel

Composer - What is it?

  • Dependency management
  • Helps to keep components as components (with a maintainer)
  • Breaking up dependencies for development (and what is needed for production system)
  • Deployment tool
  • Update your dependencies
  • Generates autoloading

Composoring Your Code

Simple Example For composer.json


{
    "name": "net_bazzline/example-library",
    "licenses": "GPLv3"
}

Releases


git tag -a 1.0.0 -m "My first release"

Consuming - Using A Library (By Using Packagist And Git)


{
    "name": "artodeto/my-application",
    "repositories":
    [
        {
            "type": "vcs",
            "url": "https://github.com/stevleibelt/php_net_component_converter"
        },
        {
            "type": "package",
            "package": {
                "name": "company/legacy-code",
                "version": "1.2.3",
                "dist": {
                    "url": "https://dev.mycompa.ny/code.tar",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        "net_bazzline/example-library": "*"
    }
}

Install


sudo su
mkdir -p /usr/local/bin/composer/
cd /usr/local/bin/composer/
curl -sS https://getcomposer.org/installer | php

Deployment - Things That Can Go Wrong

  • Github is down
  • Minimum stability or prefer stable (use dev or oder stability)
  • Versioning is hard (require a special version like 1.2.*)

Links

Easybib.com
Imagineeasy.com
Versioneye.com
Packagist.org
Satis
Semver

Others

  • Something similar to composer exists for java script
  • semantic versioning

MySql Database Clustering - by Ulf Wendel ([email protected])

  • great speaker -> try to get a free presentation :-) Ulf Wendel

Theory

  • Availability
  • Scalability
  • DistributionTransparency

What Kind Of Clusers

  • Transactions (where)
  • Synchronization (when)

Important Keywords

  • Concurrency control
    • Atomic commit
    • Atomic broadcast (virtual synchrony offering total-order delivery)
  • Certification: detect conflict
  • Quorum (better than ROWA - read from one, write to all?)
  • Fault Tolerance
  • Virtual Synchrony
  • Reliable, delivered vs receieved (for example, update transactions should receive the application layer at the same ordering)
  • MySQL DBMS (with a Reflector and Replicator connected via Group Communication System (GCS) - not available so far)
  • MySQL Cluster Replication (hybrid, extends MySQL with a Reflector Plugin (Database engine: NDB Storage Engine and) and Replicator (NDB Data Node and Replicator (NDB Data Node)) with "fire and forget" api
  • Partitioning (auto sharding)
  • Tune your partitions

Translate to de es fr it pt ja

Configuration Format Converter

Since i have to deal with a lot of configuration formats in php- or webapplications, i decided to write a conversion tool.

Today i'm happy to announce the version 1.0.0.

It is a console application (symfony/console based) and provides one command called convert. convert expects two arguemts, source and destination. The command has an option --force if destination already exists.
What do you have to provide as source or destination? For the source, you have to provide a relative path to the source configuration file. For the destination, you have to provide a relative path with file name that should contain the converted source configuration file content.

Since the conversation depends on a component, it is restricted to this capabilities. Good to know, i also maintain that component so if this cli application needs additional features, the component should be extended quite soon ;-).

The command line configuration format converter is available on github.com or via packagist.org.

Since the formater component is using the php array as exchange format between the available formats, you should know that the configuration files are underlying some restrictions. I'm working hard to create a wiki for the convertion component.

Enjoy it and feel free to report bugs or fork it.

Translate to de es fr it pt ja

current Software Components Available On Github And Packagist (Symfony Console Command, IO, Application and Configuration Format Converter)

After getting more and more into the great world of composer based systems, i tried to reuse code from my current and ongoing projects and cast them into separat components.

Right now, the follwing are available: - Symfony Console IO - Influenced by a teammate and by composer, i wanted to have IO object in my console applications. - Symfony Console Command - Since the IO component makes more sense in the command and since, again influenced by teammate and composer, i wanted to have a command code that stops me from repeating myself in different console applications. - Symfony Console Application - The last package from my lab, like the command, this package is a application with my flavor. - Component Configuration Converter - I was getting sick of converting configuration formats from one to another, so i create a component for that. Currently the following formats are available: - YAML - XML - JSON - PHPArray

All Packages are availalbe on github.com and i would be glad if you are going to test them in the real world and add some defects.

Translate to de es fr it pt ja

tool php classmap generator packagist

After a month, i've finished a tool to create a classmap from a php project. The current stable version is v1.4 and can be found on github.com as well as on packagist.org. Why? Well, obviously because i can (and wanted to learn a few things like tokens, or symfony console) ;-). But for real, when you have to deal with legacy projects or code but want to remove the strange and slow existing autoloader (with all its exception), the easiest way to do this is by using a classmap. I also tried to find a classmap generator that can deal with psr-0 and not psr-0 files, all i could find are generators that support psr-0 files. A classmap itself is just a php array. The key is the full qualified classname and the value is the relative path to the file. Creating a classmap on your own is suitable when you have to manage a number of files below 20. But when it comes to more you can not effort the time to maintain that file. So for a lot of files that are not covert by composer, the classmap generator should be well suitable. It is planned to implement a "phar" classmap generation for the upcoming version. When you want to create phar files, this could be a timesaver as well. The classmap generator is build by using symfony\console and yes, it is a joy to work with that component! Shame on me, the current version is not covered by unittests. After i implemented the current features from the todo list, this will be my major task.

The classmap generator can handle all kind of php files like: - Interface - Abstract Class - Class The generator can handle files with or without namespace. Even files with multiple definitions (interface, abstract class and class in one file) is no problem.

Furthermore, you can create multiple configuration files and update this classmaps when needed. Like well known from the composer, the classmap generator is able to create a autoloader file for you. The created autoloader will use the created classmap file and supports psr-0 autoloading.

source/link to the wiki

What is left to write? Of course i'm proud about this. What you see right now is the work of one month and after i finished the core design, i rebuild a lot by replacing my cli application class with the symfony\console component.

I hope you can use the tool. If you need help or found a bug, contact me on github.com

Translate to de es fr it pt ja