Autor: Musterknabe

Let CodeSniffer inspect your code in PhpStorm

Some time ago I wrote an article on how to format your code automatically in PhpStorm to be conform the PSR standards. In this article I want to show you how you can enable inspections in PhpStorm which throws a warning if you have code which is not PSR, e.g.

  • Whitespace at the end of line
  • No newline at the end of file
  • No newline between namespace and use statements
  • etc…

This is pretty easy. We will use squizlabs/PHP_CodeSniffer from Github.

Read More

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr

Building a Vagrant box with Debian 8, Nginx, PHP 7.0, MySQL, NodeJS and Gulp

In this tutorial I’m gonna show you how to build a Debian Vagrant box with the following technologies

  • Nginx
  • MySQL (MariaDB)
  • PHP 7.0
  • NodeJS
  • Gulp

The vagrant box will install all of this software automatically when you type in vagrant up into your shell. This tutorial assumes you already got Vagrant and a VM provider (in this tutorial Virtualbox) and have a basic understanding of Vagrant (e.g. what a Vagrantfile is, what a provisioning script is, etc.). Scroll to the end if you simnply want the complete Vagrantfile and the files needed for the provisioning script

When you see the string „projectname“ in the tutorial you can replace this string with the name of your project

Read More

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr

How to automatically append text to a git commit message

In our company, we are using a ticketing system that has Git integration. When commiting, you can reference the ticket with „refs #{Ticket-ID}“ and the ticket system automatically shows the commits that are conherent to the ticket. This is pretty simple to execute, but not everyone in the company uses it, because it gets forgotten most of the time, so I decided to write a script that automatically appends the text to a commit message, without anyone having to worry about it.

In our case, when creating feature branch we have a naming convention, that is defined as following feature/{Ticket-ID}_{Ticket-Name} which allows us to quickly find feature branches on a remote.

Now lets head to the script:

BRANCH=`git branch | grep '^\*' | cut -b3-`

echo "$1"
if [[ $BRANCH =~ $re ]];
echo "refs #"$BASH_REMATCH >> "$1";

Let me explain the script. This first two lines are simply getting the current name of the branch and defining a regex for finding the Ticket ID. The rest of the script simply checks whether the current branch name matches the regex, and if it does, adds „refs #{Ticket-ID}“ to the commit message. Otherwise, the original commit message will be used.

If you want to use this script, you have to navigate to your .git folder. Now create (if not exists) a hook folder and the folder/file

mkdir hooks && cd hooks && touch prepare-commit-msg && chmod a+x prepare-commit-msg && nano prepare-commit-msg

If you don’t have nano or don’t want to use it, forget the part after the last two ampersands and open the file how you like. Then copy the code from above into your that file, save it, and test it with a new commit. In my case it looks like this.

Screenshot 2015-07-22 16.50.16 Kopie

As you can see, I just added `test` as a commit message, however, the prepare-commit-msg hook automatically added refs #{Ticket-ID} to the message. Happy coding!

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr

Fix it the right way! – SSL Error: unable to get local issuer certificate

If you use cURL on your private machine or server you may experience some problems connecting to websites using https or redirecting you to a https version of the website. One example for this problem is the Facebook Graph API. XAMPP as an example doesn’t ship with any certificates so you have to fix this problem by yourself.

Read More

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr

Install PHP Mess Detector – phpmd – for PHPStorm

Hello fellow coders,

in this article I want to show you how to install PHP Mess Detector and allow it to work with PHPStorm.

What PHPMD does is: It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like:

  • Possible bugs
  • Suboptimal code
  • Overcomplicated expressions
  • Unused parameters, methods, properties

Please continue reading now: For this tutorial I’m using composer. Some of you might turn around now because they don’t want to use composer and just want to download a zip and install it. But I can assure you that installing something with composer does only take about 30 seconds and it works.

So let’s start. For myself I have a folder ‚work‘ where I store all my projects. In this folder I created a new one named ‚composer‘. If you have done this navigate to the folder and create a file called composer.json

Now, for phpmd to work you also need phpdepend. To get phpdepend you just prepend a line to the composer.json file. Your finished composer.json file should look like this.

    "require": {
        "pdepend/pdepend" : "1.1.0",
        "phpmd/phpmd" : "1.4.*"

This tells composer to download phpdepend and afterwards phpmd. It’s simple as that.

Next step is to download composer.phar from here and put it into the composer folder you created before. Now, simply navigate in your terminal/console to the composer folder. In my example it would be


Next step is to locate your php executable. This is done by typing

 which php 

into the console. For me my php executable is located under /usr/bin/php

When you’ve done all this you need to let composer install the dependencies. Simply type

/usr/bin/php composer.phar install

into the console and the composer does the rest. Open PHPStorm and navigate through the menu bar to your preferences. In the preferences search for PHP Mess Detector and chose the result found under the PHP tree. In the path just navigate to your phpmd executable. In my example it would be


Press the validate button to be sure, that the path is correct and everyting is loaded correctly. Afterwards go to Inspections, search again for PHP Mess Detector validation and activate it by clicking on the checkbox. You also need to check the checkboxes on the right to activate some rules you want. For an overview about the rules go here.


Bildschirmfoto 2014-07-16 um 09.55.47


If you now hit Apply on the preferences and give the project some time to reload you should be able to use PHP Mess Detector with your activated rules. Happy coding

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr
A New, Optional Way to Share and Discover Music, TV and Movies_5

Facebook und die erneute Verletzung der Privatsphäre?!

Facebook hat im Newsroom – seinem eigenem Nachrichtenblog – einen Beitrag veröffentlicht, in dem ein neues Feature vorgestellt wird. Dabei handelt es sich um die Möglichkeit, das Mikrofon während dem Schreiben eines Statusbeitrages zu aktivieren, um so Facebook erkennen zu lassen, welcher Song, welcher Film oder welche Serie im Hintergrund läuft, um diese Information in den Beitrag hinzuzufügen.



Das Problem, dass hierbei entsteht und viele als Angriff auf die Privatspähre sehen, ist folgendes: Hat ein User das Feature aktiviert, so versucht die App automatisch während des Schreibens eines Status zu erkennen, was im Hintergrund abgespielt wird. Da man es also anscheinend nicht für jeden Statusbeitrag erneut aktivieren muss, bei dem man das Feature nutzen möchte, wird nicht gewährleistet, dass das Feature nicht auch aufnimmt, wenn man gerade keinen Statusbeitrag postet.

Das sind allerdings nur vage Vermutungen, denn ich bin auch kein Fan davon, Leute, Firmen, Applikationen an den Pranger zu stellen, ohne irgendeinen Beweis zu haben. Die Funktionalität ist jedenfalls gegeben, ob sie ausgenutzt wird, ist eine andere Frage.

Ein kleiner Hoffnungsschimmer: Facebook hat selbst auf Kritik reagiert und versucht einige „Myths“ von Usern zu widerlegen. Facebook hat Folgendes über das Feature versichert:

  • Es ist komplett optional
  • Es werden keine Audiodateien oder Konversationen gespeichert
  • Das Mikrofon wird immer nur für 15 Sekunden genutzt
  • Facebook wird nicht automatisch posten, was man gerade hört
  • Die Informationen, die bei Benutzung des Features an Facebook gesendet werden, werden genau so gehandhabt wie andere Statusbeiträge: Können also jederzeit gelöscht werden.

Was noch zu sagen ist, ist, dass die App im Hintergrund laufen müsste, um, wenn sie es denn täte, Konversationen des Users und andere Audioquellen aufzunehmen, ohne, dass der User davon wissen würde, oder sich wehren könnte. Das könnte man verhindern, indem man die vollständig schließt, wenn man sie gerade nicht benutzt. Das wird allerdings eine Möglichkeit sein, die wohl, wenn sie wirklich die einzige Möglichkeit, neben dem Deinstallieren der App, ist  nicht sehr gut bei den Usern ankommt.

Um sich bereits vorher dagegen zu wehren, laufen bereits Petitionen, die dagegen vorgehen möchten. In dieser Petition wird ebenfalls darauf hingewiesen, das Facebook zwar selbst versichert, dass die Daten vertraulich behandelt werden, man trotzdessen Facebook aber nicht vertrauen sollte.


It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr