Skip to content

Instantly share code, notes, and snippets.


Andreas Frömer icanhazstring

View GitHub Profile
icanhazstring /
Last active October 17, 2022 20:12
Working with optional fields in api responses

Based on @ocramius Handling optional input parameters in PHP with vimeo/psalm and azjezz/psl I tried to use the same approach for out API implementation also with shared SDK DTOs.

Using the same OptionalField given from ocramius, we can leverage that to add optional fields into the json serialized response. This way we also add the ability to work with

  • absent values
  • adding/updating values
  • or removal of values

Given an example

View packageA.json
## Version 0.0.2
"require": {
## Version 0.0.14
"require": {
"symfony/config": "^4.4 || ^5.4"
icanhazstring /
Last active May 14, 2020 12:07
Composer archive only require-dev tree

How to archive only composer require-dev with all their dependencies

To optimize our CI builds we wanted to split our production dependencies from out dev dependencies. So that we would aquire two seperate archives which could be deployed seperatley.

For production we would only deploy production.tar.gz for testing we would deploy require.tar.gz and require-dev.tar.gz.

Unfortunately composer only comes with the composer install/update -no-dev that would ignore installation of dev dependencies.

Currently we are running two composer install while moving the vendor/ into vendor_prod/ and so forth using rsync to find the differenc between prod and dev installation and creating the proper tar balls. Sadly this creates a huge IO load.

icanhazstring /
Last active March 19, 2019 16:21
Git delete multiple remote merged branches
# git branch -r --merged master
## List all remote merged branches (master)
# awk -Forigin/ '/\/PVKZU-/ {print $2}'
## remove origin/ prefix
# tr '\n' ' '
## Replace new line with space (to get one single argument)
# xargs -rt git push origin --delete
icanhazstring / .travis.yml
Created February 14, 2019 15:00
Enable Travis PHP Build on Windows
View .travis.yml
# default os is linux
- language: php
php: 7.2
- composer install
- sh
icanhazstring / composer-windows-vagrant.bat
Last active January 24, 2019 15:37
IntelliJ/PHPStorm composer remote execution using Vagrant
View composer-windows-vagrant.bat
:: Prerequisties
:: - Git for Windows
:: - Vagrant
"C:\Program Files\Git\bin\sh.exe" -c "vagrant ssh -c 'cd /vagrant && composer %*'"
:: Setting up composer in IDE
:: Settings > Languages & Frameworks > PHP > Composer
:: Insert /path/to/your/composer.bat
icanhazstring / Vagrantfile
Created September 6, 2017 09:14
Simple Vagrantconfig PHP7.1 + composer
View Vagrantfile
Vagrant.configure("2") do |config| = "puphpet/ubuntu1604-x64"
config.vm.provision "shell", inline: <<-SHELL
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y php7.1 php7.1-xml php7.1-mbstring php7.1-zip php7.1-curl php7.1-xdebug composer
# Switch to /vagrant and install packages
cd /vagrant && composer install
icanhazstring / test.php
Created March 10, 2016 10:32
AOP Method Depedency Binding
View test.php
* @dependency($awesomeService => \Common\Service\AwesomeService)
* @dependency($megaService => \Common\Service\MegaService)
public function getFubar($id, $dependecies)
$awesomeService = $dependencies->awesomeService;
$megaService = $dependencies->megaService;
View gist:71d974a58d2f35e8abc8
## install
yum install zeromq-devel
## install
cd ~
git clone git://
cd php-zmq
phpize && ./configure
make && make install