Eliminate Fatal error: Call to a member function getHeader()/setHeader() on a non-object