Page 1 of 1

$this->load->library versus require / include x

Posted: Sun Jun 26, 2016 2:06 am
by straightlight
In Opencart v2.2.0.0 release, using the $this->load->library versus the require / include returns an undefined property message from proxy while using the require / include doesn't and outputs the results normally. The library file has indeed sticked to the same library folder with both commands used.

The library() method from the system/engine/loader.php file may require revision.

Re: $this->load->library versus require / include x

Posted: Wed Jun 29, 2016 9:54 pm
by Johnathan
In OpenCart 2.1+, files in the /system/library/ folder are automatically loaded, which is why $this->load->library returns an error message. If you place a file in that folder, you don't need that statement (or an include or require command) in OpenCart 2.1 or later.

Re: $this->load->library versus require / include x

Posted: Wed Jun 29, 2016 10:10 pm
by straightlight
Johnathan wrote:In OpenCart 2.1+, files in the /system/library/ folder are automatically loaded, which is why $this->load->library returns an error message. If you place a file in that folder, you don't need that statement (or an include or require command) in OpenCart 2.1 or later.
That is correct. Although, it is yet to know why the system/engine/loader.php file still has the library method rather than being deprecated.

Edit: Found the answer. Since Opencart v2.2.0.0, the $loader->library is propagating the libraries from the new framework file.