VishwaKumar
VishwaKumar

Reputation: 3433

ZF2: Errors in Eclipse and zend library not found

I was able to successfully install the zend skeleton framework for ZF2. But for some reason i am getting errors in eclipse and also the app cannot find the zend library classes.

enter image description here

I have this in my init_autoloader.php

    $zf2Path = false;
if (is_dir('vendor/ZF2/library')) {
    $zf2Path = 'vendor/ZF2/library';
} elseif (getenv('ZF2_PATH')) {      // Support for ZF2_PATH environment variable or git submodule
    $zf2Path = getenv('ZF2_PATH');
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
    $zf2Path = get_cfg_var('zf2_path');
}

if ($zf2Path) {
    if (isset($loader)) {
        $loader->add('Zend', $zf2Path);
    } else {
        include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        Zend\Loader\AutoloaderFactory::factory(array(
            'Zend\Loader\StandardAutoloader' => array(
                'autoregister_zf' => true
            )
        ));
    }
}

I see two zendframework folders in vendor, ZF2 is empty and zendframework folder contains bin, demos, library, resources etc folder. Is this where the library supposed to reside. If yes why do i have ZF2 empty folder?

enter image description here

Two questions: 1. How does the app find the library classes? 2. If i want to create a google places api class. Where do i put it and how do i make it accessible from any module?

Update: With Sam's comment, i did a little search and got this post that solved my eclipse problem.

Upvotes: 0

Views: 586

Answers (1)

Andrew
Andrew

Reputation: 12809

You have probably got Eclipse setup for PHP 5.1/2

Window > Preferences > PHP > PHP Interpreter > PHP Version > 5.3

It will now magically recognise the namespaces.

You can also set this on a project by project basis if you prefer.

Upvotes: 1

Related Questions