Class 'evseevnn \ Cassandra \ Database' not found

0

I'm trying to call the class 'evseevnn \ Cassandra \ Database' for that namespace without success. For this I rely on a similar case with the same architecture where I do.

The architecture is as follows,

myproject\
    |
    application\
        |
        core\
            controller.php
    ----------
    ----------
        |
        vendor\
            |
            evseevnn\
                |
                cassandra\
                    |
                    src\
                        Database.php

This is the code snippet from controller.php,

use \evseevnn\Cassandra\Database as Database;
//require '../vendor/src/evseevnn/cassandra/Database.php';

class Controller
{

    public $db = null;

    public $model = null;

    function __construct()
    {
        $this->openDatabaseConnection();
        ......
    }

    private function openDatabaseConnection()
    {
        $nodes = [
            DB_HOST
        ];

        $this->db = new Database($nodes, DB_DEFAULT_KEYSPACE);
        $this->db->connect();
    }

    .......
    .......
}

and for the file Database.php it would be as follows,

namespace evseevnn\Cassandra;

use ......
use ......

class Database {

    ......
    ......
}

Why, in the case of the same architecture and deployed in the same WAMP server, in one case it works and in the other does not?

    
asked by oggie0563 27.03.2016 в 11:55
source

1 answer

1

This is the composer.json file that I used to install the driver,

{
    "name": "root/testclient",
    "require": {
        "evseevnn/php-cassandra-binary": "dev-master"
    },
    "authors": [
        {
            "name": "Evseev Nikolay",
            "email": "[email protected]"
        }
    ]
}

And the controller.php file would look like this,

require APP . '/vendor/autoload.php';
use evseevnn\Cassandra\Database as Database;

class Controller
{

    ------
    ------

    private function openDatabaseConnection()
    {
        $nodes = [
            DB_HOST
        ];

        $this->db = new Database($nodes, DB_DEFAULT_KEYSPACE);
        $this->db->connect();
    }

    ------
}

Now it works for me correctly.

    
answered by 29.03.2016 в 11:24