CodeIgniter Forums
Best way to extend namespaced modules - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Best way to extend namespaced modules (/showthread.php?tid=67051)



Best way to extend namespaced modules - Gohrum - 01-08-2017

Hello there, 

I'm tinkering and discovering codeigniter 4, and now I face a scenario where I would like to ask which would be the best way to solve it. 

Let's say that I have a Blog controller in a separate namespace "Secondary/Blog/Controllers" with an Index method. This method just does a database query, sets a couple of vars and loads a view. 

What I want to achieve is a scenario where this controller serves as default, but sometimes I want to make changes to this controller without modifying the file so a new Blog controller will be made in the default App namespace. This new Blog extends the one in the secondary namespace and the route it's changed. 


How could use the index method and all their vars from the first controller into the second one? How could I serve views so they get printed only once? 

Thanks