Welcome Guest, Not a member yet? Register   Sign In
Removing $this-> from codeigniter 3+
#1

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
Reply
#2

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.
Follow us at https://twitter.com/LIBRETeamStudio to get a lot of new cool stuff
Reply
#3

(This post was last modified: 12-22-2014, 11:03 AM by ivantcholakov. Edit Reason: A typo. )

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
Reply
#4

(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.
Reply
#5

(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
Reply
#6

(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.
Reply
#7

(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->".
Reply
#8

(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.
Reply
#9

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

+1 !
Reply
#10

i just do not understand why people seem to be insistent on turning CodeIgniter into Laravel. If you want Laravel use Laravel.
"I reject your reality and substitute my own" - Adam Savage, M5 Inc.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB