使用Laravel Doctrine的InvalidFieldNameException

I'm converting my Zend Framework 1 app into a Laravel App. I was using Doctrine so I moved the models to Laravel. I am using laravel-doctrine

The fields are written in camelCase and when the database was created through doctrine, they were also created in camelCase, like this:

/**
 * @ORM\Entity (repositoryClass="Repositories\Customer")
 * @ORM\Table(name="customers")
 * @ORM\HasLifecycleCallbacks
 */
class Customer
{
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /** @ORM\Column(type="string", length=255, nullable=true) */
    protected $firstName;

    /** @ORM\Column(type="string", length=255, nullable=true) */
    protected $lastName;

    /** @ORM\Column(type="string", length=255, nullable=true) */
    protected $companyName;

When I do EntityManager::find('App\Entities\Customer', 1); I get this error:

An exception occurred while executing 'SELECT t0.id AS id_1, t0.firstName AS firstName_2, t0.lastName AS lastName_3, t0.company_name AS company_name_4, t0.email AS email_5, t0.phone_number AS phone_number_6, t0.type AS type_7, t0.created AS created_8, t0.updated AS updated_9, t0.jobsource_id AS jobsource_id_10 FROM customers t0 WHERE t0.id = ?' with params 1: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.company_name' in 'field list'

Is there a reason why is looking for underscore? Is there a way for me to change that?

I am using PHP 7.0.1

laraveldoctrine.org supports defining custom naming strategies:

Doctrine\ORM\Mapping\DefaultNamingStrategy Is probably the one you are looking for.

In doctrine.php config file: (after you have published it to your project)

'managers'                  => [
        'default' => [
            'naming_strategy' => 'Doctrine\ORM\Mapping\DefaultNamingStrategy',
            'dev'        => env('APP_DEBUG'),
            'meta'       => env('DOCTRINE_METADATA', 'annotations'),
            'connection' => env('DB_CONNECTION', 'mysql'),
            'paths'      => [
                base_path('app')
            ],
           ....
      ]
]

If you want a custom one, implement the naming strategy according to: http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/namingstrategy.html

Snake case is the default style for column names for many frameworks. You can specify the table column name by your property:

/** @Column(type="string", length=255, name="companyName", nullable=true) */
private $companyName;

You can change the overall naming strategy, see the docs for that. Laravel doesn't support it out of the box, but it is relatively few changes needed to make it work. If you don't want to mess with your Laravel code there is also the drop-in replacement for Doctrine that has this feature and many more built-in.