CodeIgniter Forums

Full Version: Load Library in a Core Class 2019
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi folks,

We found answers to the issue we are facing on this forum, but they are three years old:
https://forum.codeigniter.com/thread-66524-page-2.html

So, we're wondering if anyone has a better solution…

We're trying to avoid both of these poor practices:
1.  using a non-CodeIgniter solution for sending email, as well as
2.  modifying the CodeIgniter code.

We followed https://codeigniter.com/user_guide/gener...asses.html and wrote a core class MY_Log that extends CI_Log to send emails when logging an error

However, it outputs Notice: Undefined property: MP_Log::$load
followed by Fatal error: Uncaught Error: Call to a member function library()
on the line with $this->load->library('email');

Please let us know if you have a more elegant & maintainable solution than those in the link above.

Regards,
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
With out seeing your code we can not help you on this.

Post your source for your MY_Log.php

Also did you save it under ./application/core ???
Thanks for your reply InsiteFX.

For example code, please refer to https://forum.codeigniter.com/thread-66524.html - we are doing the exact same thing as the OP there - for the meanwhile, we have successfully implemented PHPMailer as per some of the advice in that thread.

Our MY_Log.php is in the correct location, and extends the Log.php successfully.


The solution that we seek in this thread would be the same as for the other thread - as mentioned, there's no purpose in showing our code, because the starting point is the original code with a by-the-book extended core class, done identically to the older thread asking the same question - it's a few years later now, and we were hoping someone might have a solution for loading CodeIgniter's email library into a core class, without modifying CI against best-practices.