I am using Symfony and I upgrade to 3.4.11.
But I have a big problem. When I run the command:
php bin/console doctrine:schema:update --dump-sql
in the terminal I have the next error:
In ClassMetadataInfo.php line 1400:
Notice: Uninitialized string offset: 0
Really, I was search and readed the docs and I can't found the error.
Thanks very much
UPDATE
$ php bin/console doc:sch:va -vvv
Mapping
-------
In ClassMetadataInfo.php line 1400:
[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Uninitialized string offset: 0
Exception trace:
Doctrine\ORM\Mapping\ClassMetadataInfo->_validateAndCompleteFieldMapping() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:2355
Doctrine\ORM\Mapping\ClassMetadataInfo->mapField() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:333
Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass() at /home/devel/tests4/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:102
Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:151
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/devel/tests4/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:333
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /home/devel/tests4/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:217
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/devel/tests4/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:115
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/SchemaValidator.php:68
Doctrine\ORM\Tools\SchemaValidator->validateMapping() at /home/devel/tests4/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/ValidateSchemaCommand.php:69
Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand->execute() at /home/devel/tests4/vendor/doctrine/doctrine-bundle/Command/Proxy/ValidateSchemaCommand.php:34
Doctrine\Bundle\DoctrineBundle\Command\Proxy\ValidateSchemaCommand->execute() at /home/devel/tests4/vendor/symfony/console/Command/Command.php:251
Symfony\Component\Console\Command\Command->run() at /home/devel/tests4/vendor/symfony/console/Application.php:964
Symfony\Component\Console\Application->doRunCommand() at /home/devel/tests4/vendor/symfony/framework-bundle/Console/Application.php:86
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/devel/tests4/vendor/symfony/console/Application.php:248
Symfony\Component\Console\Application->doRun() at /home/devel/tests4/vendor/symfony/framework-bundle/Console/Application.php:74
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/devel/tests4/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /home/devel/tests4/bin/console:39
Thanks to everyone for try to help me.
I fix my error and I found the correct answer here: https://plus.google.com/+KamilZabdyr/posts/fb5xYGyyyY8
Here the quick fix to a very common error with ORM:
PHP Notice: Uninitialized string offset: 0 in ?/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Usually it's thrown because there is a ORM column name tag empty. So check all your model files for any empty name. E.g:
@ORM\Column(name="", type="string", length=12)
This is the first Google hit for my similar problem:
bin/console doctrine:migrations:diff In MySqlSchemaManager.php line 243: Notice: Uninitialized string offset: 0
When I checked out the code on other machies it worked but this specific machine got the above failure. My problem was some interaction with MariaDB. When I upgraded from:
mysql --version mysql Ver 15.1 Distrib 10.1.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
To:
mysql --version mysql Ver 15.1 Distrib 10.3.11-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
The problem went away.
Upgrading to 10.1.38-MariaDB did not help.
I also experienced the "Uninitialized string offset: 0" with doctrine, from Symfony console.
In MySqlSchemaManager.php line 223:
Notice: Uninitialized string offset: 0
In my case it was a MariaDB version mismatch between doctrine config and (local) server version. I saw @Samuel Åslund's suggestion to update MariaDB and found that a bit excessive, but it did point me in the direction of a database-version issue.
In doctrine.yaml (Symfony 4+)
doctrine:
dbal:
server_version: 'mariadb-10.1.36'
After installing via symfony-console it was pre-configured with:
doctrine:
dbal:
server_version: 'mariadb-10.3.11'