我在 Zend Framework 项目中使用 pthreads ( http://php.net/manual/en/book.pthreads.php ) 库。问题是新线程使用与整个 ZF 初始化不同的内存范围。所以从线程范围我无法达到 Zend Framework 的功能。所以我需要在每个线程调用中加载(初始化)整个 Zend 框架。但我不知道如何正确地做到这一点......我已经在做什么(线程中的 ZF 初始化)以及实际上对我不起作用的事情:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
那么有什么想法吗?有没有正确加载整个 ZF 的例子?
您的帮助将不胜感激。