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

molerat's avatar

Laravel & VueJS Naming Conventions for variables

To make it short: In PHP we want to use snake_case for variable names (just like in the db fields), in VueJS they should be camelCase though.

  1. Do you guys recommend that - or should we use the same naming convention on both ends?
  2. If you do use snake_case in PHP and camelCase in VueJS - how do you do it without translating variables back and forth to work with the database fields?

Looking forward to your appreciated feedback. Thank you!

0 likes
1 reply
D9705996's avatar

I would recommend following the laravel coding style and although not shown if you look in the framework code it uses camelCase. If you follow the eloquent conventions you will really simplify your code base as you dont need to override the sensible defaults. This will still allow you to use _ in your db fields but a standard JS/PHP case.

One thing I would avoid at all costs is kebab-case as you cant do object->kebab-case in javascript and have to use object[kebab-case] instead

1 like

Please or to participate in this conversation.