2
votes

I have installed zend skeleton application in my local machine. I am working on ubuntu. I have installed it manually without using composer. I have given the ZF2_PATH(zend library path) in my httpd.conf. as in the below :

<VirtualHost *:80>


ServerAdmin webmaster@localhost
DocumentRoot /var/www/
SetEnv ZF2_PATH /var/www/lib/ZendFramework-2.3.1/library
SetEnv APPLICATION_ENV "development"

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

It is working fine.

I need to put this code on server. I don't have root access to configure the httpd.conf

So How can I give the library path in application.config.php? Any help would be useful.

2

2 Answers

1
votes

If you have .htaccess enabled, you can use that to set a constant. It should work too:

SetEnv ZF2_PATH /var/www/lib/ZendFramework-2.3.1/library

Or perhaps when you want to load the library relatively to your public web root:

SetEnv ZF2_PATH ./../lib/ZendFramework-2.3.1/library
0
votes

If mod_env is enabled in Apache on the server then just add the SetEnv directive in your .htaccess file. If mod_env is not enabled then you could edit init_autoloader.php to point it to the right folder. See the relevant part of init_autoloader.php below:

$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);
        $loader->add('ZendXml', $zf2Path);
    } else {
        include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        Zend\Loader\AutoloaderFactory::factory(array(
            'Zend\Loader\StandardAutoloader' => array(
                'autoregister_zf' => true
            )
        ));
    }
}