PHP port for Petrovich