Allgemein, Arbeit

Unit tests for SF2 with IntelliJ / PHPStorm and Vagrant

you require a working Symfony instance running through Vagrant.

Prerequisites

1) Install Remote Interpreter

remote_php

2) Add a Remote PHP Interpreter.

use vagrant ssh-config to get required information

Screen Shot 2016-02-17 at 14.11.57

3) Setup Path Mapping (Deployment Server)

Screen Shot 2016-02-17 at 14.47.11

 

4) Setup PHPUnit

Screen Shot 2016-02-18 at 00.04.27.png

create a file in app/phpunit.php and use it as a custom loader for phpunit:

<?php

if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
    define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/autoload.php');
}

require_once 'autoload.php';

this allows you to use @runInSeparateProcess till https://youtrack.jetbrains.com/issue/WI-29458 is fixed

 

 

Now everything should be setup and you can run the tests in Vagrant:)

Allgemein

Bitbucket Build Status from Codeship

Maybe you have heard about the new Build Status in Bitbucket – it’s awesome and shows you how good your commit / pull request is doing.

There is still a lot to be improved especially for pull requests compared to github but they will get there!

bitbucket

Integrate Codeship

Create a php file anywhere (must be reachable from the web) with the following content: snippet link

The script accepts the json data from codeship and pushes the build status (in progress | failed | success) to bitbucket. Also fill in your credentials from bitbucket!

 

that’s it:) enjoy!

mobile

Fabric.io and Ionic

If you are looking for a great framework for crash reporting with your hybrid mobile app – look no further.

 

Right now there are only a few working out of the box in this constellation – crittercism is one of them but do not go there… here are a few reasons why you should not try them

  1. ui is slow
  2. if you are in europe it will be a bit buggy – at least it was for me, telling them about errors in their error reporting code base… (this is not how I expected this to work)
  3. very slow support
  4. expensive (cheap compared to new relic but still)

 

Now to Fabric.io (formerly known as crashlytics)

The Setup

this is tricky😀 follow any guide you like for ionic, and then inside Android Studio install the Fabric.IO plugin. Warning – there are quite a lot of plugins for crashlytics that no longer work…

crashlytics_step_1Next step is to open the platform/android as a separate android project – this will enable you to add the fabric code to your application. There is also a .fabric-io file in the android project root – this will contain your application secret.

Next step is fairly simple:

ionic plugin add https://github.com/DrMoriarty/cordova-fabric-crashlytics-plugin –variable CRASHLYTICS_API_KEY=YOURKEY –variable CRASHLYTICS_API_SECRET=YOURSECRET

 

well that’s it:)

If you have not yet finished the fabric setup you’ll have to trigger an error – this is quite simple by attaching the debuger (chrome://inspect) and calling

navigator.crashlytics.simulateCrash()

Screen Shot 2016-01-18 at 23.43.04

final words

I really like crashlytics and now it’s usable for both android and ios clients! Go build your hybrid apps and add useful crash reporting

Allgemein, Arbeit

from Ubuntu to OSX

Over the years I moved from windows to linux and now to osx. Why you might ask?

Well, this is simple: I no longer have the time to configure the system to work the way I want it to. It is just supposed to do as much as possible without my intervention.

Ubuntu came pretty close to that but sadly my old vaio was breaking down.

 

I’m using OSX now for a month and I’m more that just happy! There are things missing like the “select and paste with middle mouse button” that I’m used from ubuntu and the option to move windows with the mouse and the keyboard, but it is close enough.

Uncategorized

SVN Hooks

Hi there, within a big php project you make typos. here is a small prehook script for svn that will actually prevent commits with several common and annoying mistakes:

  • Spaces in filenames
  • Spaces prior to the first <?php tag
  • PHP Short Tags
  • windows line endings

[bash]#!/bin/bash

# configuration
DO_DOS_FILE_CHECK=1
DO_SPACE_FILE_CHECK=1
DO_PHP_SHORT_TAG_CHECK=1
DO_SPACE_BEFOR_PHP_CHECK=1

REPOS=”$1″
TXN=”$2″

SVNLOOK=/usr/bin/svnlook
TMPFILE_ORIG=/tmp/svnhook_$TXN
TMPFILE_UNIX=/tmp/svnhook_unix_$TXN

FILES=`$SVNLOOK changed “$REPOS” -t “$TXN” | sed -r ‘s/^[D].*$//;s/^[AU]{1,2}s+//’`
DOS_FILES=””
SPACE_FILES=””
PHP_SHORT_TAG_FILES=””
SPACE_BEFOR_PHP_FILES=””

IFS=$’n’

for FILE in $FILES
do
LAST=${FILE#${FILE%?}}

# echo “FILE = ‘$FILE'” >&2

if [ “$LAST” = “/” ]; then
continue
else
if [ -n $DO_SPACE_FILE_CHECK ]; then
# space in filename check
SPACE_VIOLATIONS=`echo “$FILE” | grep -l ” “`

if [ -n “$SPACE_VIOLATIONS” ]; then
SPACE_FILES=”$SPACE_FILESn$FILE”
continue
fi
fi

$SVNLOOK cat “$REPOS” -t “$TXN” “$FILE” > $TMPFILE_ORIG || continue

if [ -n $DO_DOS_FILE_CHECK ]; then
# check windows line endings
VIOLATIONS=`grep -cIls $’r$’ $TMPFILE_ORIG` >&2

if [ -n “$VIOLATIONS” ]; then
DOS_FILES=”$DOS_FILESn$FILE”
fi
fi

if [ -n $DO_PHP_SHORT_TAG_CHECK ]; then
# check php short tags
VIOLATIONS=`grep -rn ‘&2
if [ -n “$VIOLATIONS” ]; then
PHP_SHORT_TAG_FILES=”$PHP_SHORT_TAG_FILESn$FILE: $VIOLATIONS”
fi
fi

if [ -n $DO_SPACE_BEFOR_PHP_CHECK ]; then
# check for space prior to php tag
VIOLATIONS=`head -n 1 $TMPFILE_ORIG | grep ‘^s&2
if [ -n “$VIOLATIONS” ]; then
SPACE_BEFOR_PHP_FILES=”$SPACE_BEFOR_PHP_FILESn$FILE”
fi
fi
fi
done

rm -f $TMPFILE_ORIG
rm -f $TMPFILE_UNIX

if [ “$DOS_FILES” != “” ] || [ “$SPACE_FILES” != “” ] || [ “$SPACE_BEFOR_PHP_FILES” != “” ] || [ “$PHP_SHORT_TAG_FILES” != “” ]; then
echo -e “n” >&2
if [ “$DOS_FILES” != “” ]; then
echo “ONLY UNIX LINEENDINGS ALLOWED!!!” >&2
echo “the following file contains Windows / Mac Lineendings:” >&2
echo -e $DOS_FILES >&2
echo -e “n” >&2
fi

if [ “$SPACE_FILES” != “” ]; then
echo “SPACES ARE NOT ALLOWED IN FILE / FOLDER NAMES!!!” >&2
echo “the following file contain spaces:” >&2
echo -e $SPACE_FILES >&2
echo -e “n” >&2
fi

if [ “$SPACE_BEFOR_PHP_FILES” != “” ]; then
echo “SPACES ARE NOT ALLOWED BEFOR THE PHP TAG IN THE FIRST LINE!!!” >&2
echo “the following file contain spaces:” >&2
echo -e $SPACE_BEFOR_PHP_FILES >&2
echo -e “n” >&2
fi

if [ “$PHP_SHORT_TAG_FILES” != “” ]; then
echo “SHORT PHP TAGS ARE NOT ALLOWED!!!” >&2
echo “the following file contain short tags” >&2
echo -e $PHP_SHORT_TAG_FILES >&2
echo -e “n” >&2
fi

exit 2
fi

# All checks passed, so allow the commit.
exit 0
[/bash]