Refer: How you name variables in Laravel & PHP.
$firstName or $first_name?
$userid or $userId or $user_id?
PSR-1 Coding Standards have this to say:
Whatever naming convention is used SHOULD be applied consistently within a reasonable scope. That scope may be vendor-level, package-level, class-level, or method-level.
Personally I use mixedCase for properties and underscored separated for variables defined in a function, method or in global scope.
The important thing is to use it consistently so that you will be able to readily tell if a variable is being misused (i.e. I know if I see a camel cased variable without an object operator I know it is an error).
Larvel 4's coding guidelines state that they adhere to PSR-1 with no mention of the representation of variables.
Laravel 3: $first_name
Laravel 4: $firstName
Why? Cause you following the framework convention makes your code easier too read for other developers which join the project later.
Thats not my personal prefer. Thats what the crowd hopefully do. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With