CodeIgniter Forums
How to override system Helper? It's still calling it. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: How to override system Helper? It's still calling it. (/showthread.php?tid=81300)



How to override system Helper? It's still calling it. - amityweb - 02-14-2022

I thought this page meant I could copy a helper of the same name from into app/Helpers, and it would use that file instead of the system one? https://codeigniter.com/user_guide/general/helpers.html#extending-helpers
So I duplicated url_helper.php to app/Helpers, but my CI app is loading both. 
So how can I disable using the system one in /vendor/codeigniter4/framework/system/Helpers/? 
My reason is I am trying to load Wordpress functions into my CI app and both use site_url(). So I need CI to not load its own url_helper.php file, and I will duplicate it into app/Helpers and change the site_url() references to ci_site_url(). 
But the problem is I still receive the error that site_url() is declared in /vendor/codeigniter4/framework/system/Helpers/url_helper.php. 
PHP Code:
Fatal errorCannot redeclare site_url() (previously declared in /home/myapp/webapps/myapp/vendor/codeigniter4/framework/system/Helpers/url_helper.php:80



RE: How to override system Helper? It's still calling it. - iRedds - 02-15-2022

No, this means that all found files will be included. Both in the application directory and in the framework directory.
You cannot disable.


RE: How to override system Helper? It's still calling it. - amityweb - 02-16-2022

Ok thank you. This was posted as a solution on Stack exchange to the issue I mentioned. So I guess it was not a solution then.

If I include Wordpress files earlier, before CI includes the helpers, I think it works ok. Because CI checks if the function exists first, but WP does not.