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


Messages In This Thread
Use more PHP standards (namespaces) - by rtorralba - 04-07-2015, 04:11 AM
RE: Use more PHP standards (namespaces) - by cjj - 04-08-2015, 10:50 PM
RE: Use more PHP standards (namespaces) - by Narf - 05-05-2015, 07:57 AM
RE: Use more PHP standards (namespaces) - by Narf - 06-14-2016, 12:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB