0

im newbie in code igniter, im okay with the underscore convention, but i want to make my own libraries/extended core CI classes/custom function with camelCase convention.

i tried to change :

 $config['subclass_prefix'] = 'My';

and the create :

class MyController
class MyModel
myFunction

and it works, but as the documentation said that i shouldn't use camelCase convention.. I just use camelCase so that i know which is the CI's core classess/functions and which is my custom.

until now(3 days with CI) it doesn't produce any trouble with CI and im enjoying this, but yeah im just newbie in CI if anyone have/had bad experience using camelCase with CI please let me know..

the question is:

is it okay for me to use camelCase for custom class/function in CI? i mean will it become trouble in the CI?

CI version 2.X

PHP 5.4

mohur
  • 1,785
  • 4
  • 16
  • 25
  • Did you read http://ellislab.com/codeigniter/user-guide/general/core_classes.html ? – kittycat Mar 10 '13 at 15:48
  • erm yes i did. the `MyController` above is from `MyController extends CI_Controller` which i put in `/application/core` with name `MyController.php` and i have several functions with camelCase inside `MyController` i just dont put it on the post to make my question simpler. – mohur Mar 10 '13 at 15:51

1 Answers1

0

If you’re not a fan of CodeIgniter naming convention tyranny and want to use CamelCase or lowerCamelCase file names do this

  1. Make a file called path/to/app/application/core/My_Loader.php
  2. In the file make a class like this

    <?php
        class My_Loader extends CI_Loader
        {
    
        }
    
  3. Find the CI_Loader class in path/to/app/system/core/Loader.php

  4. Copy method public function model
  5. Paste it into My_Loader
  6. Delete $model = strtolower($model); and $model = ucfirst($model); from the My_Loader::model method.

Shazam!

Josh Woodcock
  • 2,683
  • 1
  • 22
  • 29