Zend Framework : Could not determine temp directory, please specify a cache_dir manually

后端 未结 8 731
忘了有多久
忘了有多久 2021-01-14 15:44

I am just learning Zend Framework. I created a simple Zend_Form and when I submitted the form I got following error:

An error occurred
Application error
Exce         


        
相关标签:
8条回答
  • 2021-01-14 16:09

    you can put in .htaccess

    SetEnv TEMP /tmp
    
    0 讨论(0)
  • 2021-01-14 16:09

    I think this solve the problem , it solved it for me

    Zend_Date::setOptions(array('cache' => $cache)); // Active aussi pour Zend_Locale
    Zend_Translate::setCache($cache);
    

    add it after setting your cache in the bootstrap.php

    0 讨论(0)
  • 2021-01-14 16:14

    Turn off/disable cache :) Why do you use it for simple app, when learning? There are more important things to learn ;)

    0 讨论(0)
  • 2021-01-14 16:16

    I was using 'memcached' instead of 'File', so my problem was a little bit different. I solved this by using:

            $registry = Zend_Registry::getInstance ();
            $frontendOptions =
            array (
                'lifetime' => APPLICATION_ENV == 'development' ? '10' : '3600', 
                'automatic_serialization' => true
            );
    
    
        $backendOptions = array(
                            'servers' => array( array(
                                'host' => APPLICATION_ENV == 'development' ? '***' : '***', 
                                'port' => '***'
                            ) ),
                            'compression' => true
        );
    
        $cache = Zend_Cache::factory ( 'Core', 'Memcached', $frontendOptions, $backendOptions );
    
    // Below is the fix for the problem! It appears that some validators / translates are caching
    Zend_Locale::setCache($cache);
    Zend_Translate::setCache($cache);
    
    0 讨论(0)
  • 2021-01-14 16:19

    Well, it says

    "Please specify a cache_dir manually"
    

    So do that.

    Example from Reference Guide:

    $frontendOptions = array(
       'lifetime' => 7200, // cache lifetime of 2 hours
       'automatic_serialization' => true
    );
    
    $backendOptions = array(
        'cache_dir' => '/path/to/cache' // Directory where to put the cache files
    );
    
    // getting a Zend_Cache_Core object
    $cache = Zend_Cache::factory('Core',
                                 'File',
                                 $frontendOptions,
                                 $backendOptions);
    

    Equivalent when using the Cache Resource Plugin:

    resources.cachemanager.database.frontend.name = Core
    resources.cachemanager.database.frontend.customFrontendNaming = false
    resources.cachemanager.database.frontend.options.lifetime = 7200
    resources.cachemanager.database.frontend.options.automatic_serialization = true
    
    resources.cachemanager.database.backend.name = File
    resources.cachemanager.database.backend.customBackendNaming = false
    resources.cachemanager.database.backend.options.cache_dir = "/path/to/cache"
    resources.cachemanager.database.frontendBackendAutoload = false
    

    Reference:

    • http://framework.zend.com/manual/en/zend.cache.backends.html#zend.cache.backends.file
    • http://framework.zend.com/manual/en/zend.cache.introduction.html
    • http://zendframework.com/manual/en/zend.application.available-resources.html
    0 讨论(0)
  • 2021-01-14 16:21

    Something like this should be helpful:

    $_SERVER['TEMP'] =  realpath(dirname(__FILE__) . '/tmp');
    
    0 讨论(0)
提交回复
热议问题