Skip to content

Instantly share code, notes, and snippets.

View icanhazstring's full-sized avatar

Andreas Frömer icanhazstring

View GitHub Profile
@icanhazstring
icanhazstring / 01-introduction.md
Created September 18, 2023 09:46 — forked from gemmadlou/01-introduction.md
WordPress Composer Starter (Steps)

Develop WordPress as a Modern PHP Project with Composer


WordPress is popular because it's easy to setup without much technical know-how. However, to build a more robust PHP project with command line deployments, updates and ongoing maintenance, working with WordPress out-of-the-box raises specific challenges:


  • How can we make our WordPress projects portable between developers?
@icanhazstring
icanhazstring / optional-fields-in-api.md
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

## Version 0.0.2
{
"require": {
}
}
## Version 0.0.14
{
"require": {
"symfony/config": "^4.4 || ^5.4"
@icanhazstring
icanhazstring / how-to-archive-only-composer-dev-dependencies.md
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
icanhazstring / delete-merged-branches.sh
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
icanhazstring / .travis.yml
Created February 14, 2019 15:00
Enable Travis PHP Build on Windows
# default os is linux
matrix:
include:
- language: php
php: 7.2
before_script:
- composer install
after_script:
- sh .travis.coverage.sh
@icanhazstring
icanhazstring / composer-windows-vagrant.bat
Last active January 24, 2019 15:37
IntelliJ/PHPStorm composer remote execution using Vagrant
:: 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
icanhazstring / Vagrantfile
Created September 6, 2017 09:14
Simple Vagrantconfig PHP7.1 + composer
Vagrant.configure("2") do |config|
config.vm.box = "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
icanhazstring / test.php
Created March 10, 2016 10:32
AOP Method Depedency Binding
/**
* @dependency($awesomeService => \Common\Service\AwesomeService)
* @dependency($megaService => \Common\Service\MegaService)
*/
public function getFubar($id, $dependecies)
{
$awesomeService = $dependencies->awesomeService;
$megaService = $dependencies->megaService;
$awesomeService->getData($id);
## install
yum install zeromq-devel
## install zmq.so
cd ~
git clone git://github.com/mkoppanen/php-zmq.git
cd php-zmq
phpize && ./configure
make && make install