Testing out CakePHP's Inflector magic

Want to know what the inflector is going to do to your code, what the name of your model should be when you have a wierd table name? Just enter it in here and look at what cake will generate.

This is currently running CakePHP

The output is what has happend for that particular method, and the other items in the array are the inflicted version being convered to other types. eg pluralizing 'user' becomes 'users' and then camelizing 'users' is becomes 'Users'. You can find problems with your table names and classes doing this for example if you were to use a table called 'this' cake would expect the model 'Thi' by default.

When ever you pluralize something and then singularize it it should be the same. var_dump(Inflector::singularize(Inflector::pluralize($var)) === var_dump($var)) should generally give you the output "true", if it does not you need to use some custom rules or use another name.

Inflector::pluralize(CakePHPInflectorMagic)

Convert models to controllers MyUser -> MyUsers

becomes :: CakePHPInflectorMagics
singularize :: CakePHPInflectorMagic



Inflector::singularize(CakePHPInflectorMagic)

Convert controllers to models MyUsers -> MyUser

becomes :: CakePHPInflectorMagic
pluralize :: CakePHPInflectorMagics



Inflector::camelize(CakePHPInflectorMagic)

Used with singularize to make tables into models my_users -> MyUsers

becomes :: CakePHPInflectorMagic
underscore :: cake_p_h_p_inflector_magic



Inflector::underscore(CakePHPInflectorMagic)

models to tables with the pluralize MyUser -> my_user

becomes :: cake_p_h_p_inflector_magic
camelize :: CakePHPInflectorMagic



Inflector::humanize(CakePHPInflectorMagic)

convert models and controllers to human names MyUser -> My user

becomes :: CakePHPInflectorMagic
underscore :: cake_p_h_p_inflector_magic



Inflector::tableize(CakePHPInflectorMagic)

Calls underscore and pluralize to make model names MyUser -> my_user -> my_users

becomes :: cake_p_h_p_inflector_magics



Inflector::classify(CakePHPInflectorMagic)

Table names to models my_users -> MyUser

becomes :: CakePHPInflectorMagic



Inflector::variable(CakePHPInflectorMagic)

Was used for $this->set in 1.2 to make 'some_var' -> 'someVar'

becomes :: cakePHPInflectorMagic
underscore :: cake_p_h_p_inflector_magic
camelize :: CakePHPInflectorMagic



Inflector::slug(CakePHPInflectorMagic)

Remove funny chars for a url

becomes :: CakePHPInflectorMagic