clean up the php port, adding cli mode support