Welcome Guest, Not a member yet? Register   Sign In
Poll: Use namespaces?
You do not have permission to vote in this poll.
yes
89.00%
89 89.00%
no
7.00%
7 7.00%
maybe
4.00%
4 4.00%
Total 100 vote(s) 100%
* You voted for this item. [Show Results]

Use more PHP standards (namespaces)
#1

(This post was last modified: 04-07-2015, 05:44 PM by rtorralba.)

Hi,

I completly agree with keep codeigniter simple, but i think some things that codeigniter do can be changed for more standard style.

For example use namespaces instead loader class or core clases overwritting with its prefix defined on the configuration, or codeigniter prefixes (CI_) for not repeat class names.

E.g.

For create a master controller for my app make something like:


PHP Code:
namespace MyApp\Controllers;

class 
MasterController extends CI\Controller 

And then in the final controller:

PHP Code:
use MyApp\Controllers;

class 
ClientController extends MasterController 

And apply this logic to declare and use models instead use a CI_Loader:

PHP Code:
namespace MyApp\Models;

use 
CI\Libraries\DB as DB

class ClientModel extends CI\Model {

 
 public function getRows()
 
 {
 
   return DB::get('clients')->result();
 
 

And then in the controller:

PHP Code:
use MyApp\Models;

$clientModel = new ClientModel();

$clients $clientModel->getRows(); 

And apply this to all codeigniter elements, DB, views...

I think this don't add complexity, don't add orm, template engine, etc... Simply replace codeigniter thought the way to do certain things for php standard way

Greetings.
Reply
#2

I agree. Simple, but modern also
Reply
#3

Good, however this won't be like CI we all know.
I guess the migration will be very hard.
Reply
#4

CI is a PHP framework.
CI should be developed along with PHP.
Reply
#5
Sad 

I'll miss it
PHP Code:
$this->CI =& get_instance() 
Reply
#6

I support the implementation of namespaces in CI.
Share what you know,
Learn what you don't
Reply
#7

While I think CI should be namespaced and should recognize application classes which use namespaces, I don't think it should require everyone to completely rewrite their applications to upgrade from CI3 to CI4. There is still room for backwards compatibility while updating the core classes to use and support namespaces.

It could be as simple as use of the loader and/or get_instance() to indicate that CI classes should be available via $this-> for legacy support.
Reply
#8

(04-13-2015, 10:26 AM)mwhitney Wrote: While I think CI should be namespaced and should recognize application classes which use namespaces, I don't think it should require everyone to completely rewrite their applications to upgrade from CI3 to CI4. There is still room for backwards compatibility while updating the core classes to use and support namespaces.

It could be as simple as use of the loader and/or get_instance() to indicate that CI classes should be available via $this-> for legacy support.


Hi,


I think is not necessary maintain the backward compatibility. Codeigniter has some solutions for deficiencies that php had in the past but not now. For example loader class, for load classes or prefixes use like CI_ to prevent to use same name classes.

This problems are now fixed natively in php, then, is not necessary to add other way to make some things.

In addition to this, ci will be easier to new users that knows only php, because if somebody know php then can understand code like $object = new CI\Models\Client(); but don't understand ci style code like $this->load->('client_model') and he should to learn it.

I think is enough maintain ci3 fixing bugs and possible exploits and make a new version with the same codeigniter simplicity but using native php.

In fact I think modern PHP codeigniter can be easier and simple because all code unnecessary can be deleted making it easier to learn and easier to maintain.

Greetings.
Reply
#9

Not just namespaces .. Traits , interfaces and others must be added to CI.
Even base PHP interfaces and class's as Iterator, ArrayAccess, Serializable, Closure, can be used on some places..

CI must go closer to PHP base practices in OOP programming..
Best VPS Hosting : Digital Ocean
Reply
#10

(This post was last modified: 04-14-2015, 09:23 AM by mwhitney.)

(04-13-2015, 02:07 PM)rtorralba Wrote: I think is not necessary maintain the backward compatibility. Codeigniter has some solutions for deficiencies that php had in the past but not now. For example loader class, for load classes or prefixes use like CI_ to prevent to use same name classes.

Short-term backwards compatibility is how any platform maintains its existing user base, whether it is an OS, a programming language, an API, or a framework. Even if it requires an extra compatibility layer, it is usually worth the extra effort to provide an easier upgrade path for existing users.

The reason for this is simple: if I have to rewrite my existing application from scratch to move from CI3 to CI4, I then have one more reason to evaluate other frameworks and one less reason to stay with CI.

Some other PHP frameworks have resisted providing backwards compatibility, and many of them have suffered for it.

(04-13-2015, 02:07 PM)rtorralba Wrote: I think is enough maintain ci3 fixing bugs and possible exploits and make a new version with the same codeigniter simplicity but using native php.

Given that the end-of-life date for CI2 has been set for 6 months from now, I really don't have any faith in the idea of long-term support for an older version of the framework. While the development time of CI3 has been exceptionally long, the maintenance of CI2 during that time has not been stellar, either (though neither is necessarily the fault of the current developers/maintainers).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB