Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

What is a good way/place to transform db names?

I need to translate some strings to other strings, not from one language to another.

Right now I have list of table names in the DB but the names don't always match and sometimes needs to be completely changed.

For example I get list of tables:

table1
table2
some_table3

And I want to have a file that translates them:

table1 -> My Table
table2 -> My Second Table
some_table3 -> One More Table
// and many more

or translate the column names of the tables themselves: (sort of dictionary)

x_col -> X Column
y_col -> The Y Column
// and many more

Should I use enum? Or just an array? And where do I place these files?

0 likes
4 replies
lakuapik's avatar

if its a simple list, i personally just use array and put them in config file.

but if there will be an operation before displaying the string, like make it uppercase or anything, i would prefer enums, and put it in /app/Enums.

1 like
Ligonsker's avatar

@lakuapik thanks! And if that's in config file, you put it in the config folder or create maybe Helpers folder?

Also how would I use it? Should I set it as a service provider so that I can use it conveniently in blade, something like:

{{ transform[$column_name] }}

Or any other way? Maybe I can do it via config file but not sure how to make it work in blade without using a use statement inside a blade file which I don't want

Ligonsker's avatar

@Tray2 nice, didn't see that. However sometimes the column names don't match exactly so even using such methods won't work and require manual "translations"

Please or to participate in this conversation.