Refactor PHP API library structure