Php refactoring

resolves #27