CodeIgniter Forums
Removing $this-> from codeigniter 3+ - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Removing $this-> from codeigniter 3+ (/showthread.php?tid=572)



Removing $this-> from codeigniter 3+ - kharota - 12-21-2014

I don't know when codeigniter would remove $this and we would be using like

$load->view();

or 

Load::view();

$this-> we have to write again and again in all the codes. I hope codeigniter would start using faceds like laravel or they would find a different and better way.


would not it save the lots of time of developers?



thanks


RE: Removing $this-> from codeigniter 3+ - libreteam_studio - 12-22-2014

i think it's not possible with php (problem of global variable). but i have an idea for this

Code:
$load = $this->load;
$load->view("YOUR_VIEW_HERE");

or kind of helper

Code:
function view($path)
{
    $ci = &get_instance();
    return $ci->load->view($path);
}

and autoload this helper
hope this help.


RE: Removing $this-> from codeigniter 3+ - ivantcholakov - 12-22-2014

Whether $this should be used or not requires research, in my opinion. FuelPHP 1.x started with static interfaces, then for the future FuelPHP 2.0 maybe they are going to change their mind. One of the reasons I remember was how easyly unit-test are written. Perhabs I am not quite precise exactly at this moment. See an old article of theirs: http://fuelphp.com/blogs/2012/06/context-matters


RE: Removing $this-> from codeigniter 3+ - includebeer - 12-24-2014

(12-21-2014, 03:10 PM)kharota Wrote: would not it save the lots of time of developers?

Dev will save no time at all,  because it breaks compatibility for absolutely no good reason. All previous code will need to be fixed to work with this new syntax.


RE: Removing $this-> from codeigniter 3+ - levydavid - 12-27-2014

(12-22-2014, 02:11 AM)libreteam_studio Wrote:
Code:
function view($path)
{
   $ci = &get_instance();
   return $ci->load->view($path);
}

Hi maybe it is offtopic but why in php 5 we have to write $CI =& get_instance(); and not $CI = get_instance();
get_instance returns an object which passed by reference?
Thanks


RE: Removing $this-> from codeigniter 3+ - no1youknowz - 12-27-2014

(12-24-2014, 12:12 PM)includebeer Wrote: Dev will save no time at all,  because it breaks compatibility for absolutely no good reason. All previous code will need to be fixed to work with this new syntax.

Sorry to say and this isn't personal attack. So please don't take it as one.

But its comments like this from developers like yourself who stifle innovation on PHP. You expect your 10 years code (I know an exaggeration) to still work with new releases.

Everyone be it Linux, Microsoft, Oracle depreciate functions in their software, or make out of date production systems with newer versions of software.

CI 4.X. Should be a complete break from everything else. It should have todays ideas and not yesterdays hacks.

The choice should be simple. Don't want to upgrade and cant move your code? Stay on 3.0.

Want to move with the times, welcome to CI 4.X for your existing projects that you can move or your newer projects.

Do you see Laravel developers cry when a newer release comes out? No, they cant wait to use the newer functionality and extras for their applications.


RE: Removing $this-> from codeigniter 3+ - includebeer - 12-27-2014

(12-27-2014, 12:26 PM)no1youknowz Wrote:
(12-24-2014, 12:12 PM)includebeer Wrote: Dev will save no time at all,  because it breaks compatibility for absolutely no good reason. All previous code will need to be fixed to work with this new syntax.

Sorry to say and this isn't personal attack.  So please don't take it as one.

But its comments like this from developers like yourself who stifle innovation on PHP.  You expect your 10 years code (I know an exaggeration) to still work with new releases.
...

No offence taken. I understand your point. In fact, the best is a good balance between innovation and compatibility.

I'm not against evolution of the framework. What I hate is when everything is changed every six month and it break everything. In particular when it's changed so the code is more beautiful... or it's the new trend to write code that way... and it adds nothing new.

At the very least, if the dev team decide to break compatibility, there must be a good reason and a detailed upgrade guide.

For this particular example, I don't see the benefit in removing "$this->".


RE: Removing $this-> from codeigniter 3+ - peterdenk - 12-28-2014

(12-27-2014, 07:23 PM)includebeer Wrote: At the very least, if the dev team decide to break compatibility, there must be a good reason and a detailed upgrade guide.

Plus the old version MUST receive bug fixes for a reasonable time.


RE: Removing $this-> from codeigniter 3+ - includebeer - 12-28-2014

(12-28-2014, 06:50 AM)peterdenk Wrote: Plus the old version MUST receive bug fixes for a reasonable time.

+1 !


RE: Removing $this-> from codeigniter 3+ - Hobbes - 12-28-2014

i just do not understand why people seem to be insistent on turning CodeIgniter into Laravel. If you want Laravel use Laravel.