Search code examples
symfonycassandradatastax

Cassandra compile error in Symfony 3.4


I compiled datastax driver for cassandra with php7.1 and installed the bundle https://packagist.org/packages/hendrahuang/cassandra-bundle

But when i try to run the "bin/console cassandra:schema:create", I got the compile error

Compile Error: Declaration of CassandraBundle\Cassandra\ORM\EntityManager::execute(Cassandra\Statement $statement, ?Cassandra\Exec
  utionOptions $options = NULL) must be compatible with Cassandra\Session::execute($statement, $options = NULL)

I searched it in google but i couldn't find any solution.


Solution

  • I think you've built the Cassandra extension version 1.3 where the definition of method execute has changed from 1.2 for which matches cassandra-bundle latest version tag 1.4 https://docs.datastax.com/en/developer/php-driver/1.3/api/Cassandra/interface.Session/

    To fix your problem you have two solutions:

    1. Build the extension version 1.2 for which the definition of execute method is the same with the one from cassandra-bundle. https://docs.datastax.com/en/developer/php-driver/1.2/api/Cassandra/interface.Session/#method-execute with https://github.com/Hendra-Huang/CassandraBundle/blob/v1.4/Cassandra/ORM/EntityManager.php#L405

    2. Use branch master from cassandra-bundle for which the definition of execute method is the same https://github.com/Hendra-Huang/CassandraBundle/blob/master/Cassandra/ORM/EntityManager.php#L411 with https://docs.datastax.com/en/developer/php-driver/1.3/api/Cassandra/interface.Session/#method-execute

    To change to branch master update your composer.json: "hendrahuang/cassandra-bundle": "dev-master" then composer update hendrahuang/cassandra-bundle You might need to change the minimum-stability setting in your composer.json https://getcomposer.org/doc/04-schema.md#minimum-stability

    Solution 1 is the safer one. You don't want to use master branch for your dependencies.

    Hope it helps