This article is part of the CakeDC Advent Calendar 2025 (December 18th 2025)
I have been working with CakePHP for more than 15 years now. I love the conventions. I also love that I don't have to configure every single XML file, like in the old Java days.
But let's be honest: as a Spanish native speaker, naming things in English can sometimes be a nightmare.
In Spanish, life is simple. You have a Casa (house), you add an "s", you have Casas (houses). You have a Camión (truck), you add "es", you have Camiones (trucks). Logic!
But in English? You have a mouse, and suddenly you have mice. You have a person, and it becomes people. You have a woman and it becomes women.
This is why the Inflector class is not just a utility for me. It is my personal English teacher living inside the /vendor folder.
It covers my back
When I started with CakePHP 15 years ago, I was always scared to name a database table categories. I was 100% sure that I would break the framework because I would name the model Categorys or something wrong.
But! CakePHP knows better. It knows irregular verbs and weird nouns better than I do.
use Cake\\Utility\\Inflector;
// The stuff I usually get right
echo Inflector::pluralize('User'); // Users
// The stuff I would definitely get wrong without coffee
echo Inflector::pluralize('Person'); // People
echo Inflector::pluralize('Child'); // Children
Variable Naming (CamelCase vs underscore)
The other battle I have fought for 15 years is the variable naming convention. Is it camelCase? Is it PascalCase? Is it underscore_case?
My brain thinks in Spanish, translates to English, and then tries to apply PSR-12 standards. It is a lot of processing power.
Fortunately, when I am building dynamic tools, I just let the Inflector handle the formatting:
// Converting my database column to a nice label
echo Inflector::humanize('published_date');
// Output: Published Date
// Converting a string to a valid variable name
echo Inflector::variable('My Client ID');
// Output: myClientId
When Spanglish happens
Of course, after so many years, sometimes a Spanish word slips into the database schema. It happens to the best of us.
If I create a table called alumnos (students), CakePHP tries its best, but it assumes it is English.
Inflector::singularize('alumnos') -> Alumno (It actually works! Lucky.)
But sometimes it fails funny. If I have a Jamon (Ham), Cake thinks the plural is Jamons.
So, for those rare moments where my English fails, I can teach the Inflector a bit of Spanish in bootstrap.php:
Inflector::rules('plural', \[
'/on$/i' \=\> 'ones' // Fixing words ending in 'on' like Cajon, Jamon...
\]);
Conclusion
We talk a lot about the ORM, Dependency Injection, and Plugins. Today however, I wanted to say "Gracias" to the humble Inflector. It has saved me from typos and grammar mistakes since 2008.
Challenge for today: Go check your code. Are you manually formatting strings? Stop working so hard and let the Inflector do it for you.
This article is part of the CakeDC Advent Calendar 2025 (December 18th 2025)