同一根文件夹中的多个 Zend 框架项目

发布于 2024-07-16 01:16:18 字数 243 浏览 5 评论 0原文

Zend Framework 项目结构假定每台服务器仅运行一个应用程序,例如 localhost/guessbook,其中控制器和内容位于该级别之上的一个文件夹。

我如何在本地主机中拥有一些不同的基于 ZF 的项目,以便像处理常规 php 脚本应用程序一样解决它们 - 使用 localhost/app1、localhost/app2?

理想情况下,我想要没有 DocumentRoot,我想使用浏览器立即在应用程序之间切换。

Zend Framework project structure presumes you run only one application per server, like
localhost/guessbook, where controllers and stuff are located one folder above that level.

How can I have a few different ZF-based projects in my localhost so that to address them like I do with regular php script apps - with localhost/app1, localhost/app2?

Ideally, I want to do without DocumentRoot, I want to switch between apps instantly using browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

十二 2024-07-23 01:16:18

我不明白到底是什么问题? 也许您指的是发送到 /index.php 的典型重写规则? 好吧,您可以将重写规则从 更改为

RewriteRule ^.*$ /index.php [NC,L]

RewriteRule ^/app1/.*$ /app1/index.php [NC,L]
RewriteRule ^/app2/.*$ /app2/index.php [NC,L]

bootstrap.php 中定义所有包含路径,这样您就可以共享 Zend Framework 库。

I don't quiet understand what's the problem? Perhaps you're referring at typical rewrite rules that send to /index.php? Well, you can change that rewriting rules from

RewriteRule ^.*$ /index.php [NC,L]

to

RewriteRule ^/app1/.*$ /app1/index.php [NC,L]
RewriteRule ^/app2/.*$ /app2/index.php [NC,L]

In bootstrap.php you define all the include path, so you can have Zend Framework libraries shared.

咿呀咿呀哟 2024-07-23 01:16:18

我认为你在这一点上是错误的。 您可以在同一主机名上拥有多个 zend 框架应用程序。 即我一直在我的服务器上使用多个magento 安装来尝试一些东西。 据我所知,Zend 没有固定的文件结构(我选择框架的原因之一)

您甚至可以将 Zend 库放置在 webroot 文件夹之外,并使用如下所示的方式调用它:

$lib = realpath(dirname(basename(__FILE__)) . '/../../../lib');
set_include_path(get_include_path() . PATH_SEPARATOR . $lib);


$rootDir = dirname(dirname(__FILE__));
        define('ROOT_DIR', $rootDir);

        set_include_path(get_include_path()
            . PATH_SEPARATOR . ROOT_DIR . '/library/'
            . PATH_SEPARATOR . ROOT_DIR . '/app/models/'
        );

        include 'Zend/Loader.php';
        spl_autoload_register(array('Zend_Loader', 'autoload'));

        // Load configuration
        Zend_Registry::set('configSection', $configSection);
        $config = new Zend_Config(new Zend_Config_Ini(ROOT_DIR.'/application/config.ini', $configSection));
        Zend_Registry::set('config', $config);

I think that you are wrong on this one. You can have multiple zend framework application on the same hostname. I.e. i've been using multiple magento's installation on my server in order to try out things. Zend doesn't have fixed file structure as far as i know (one of the reason of my choice of framework)

You can place even place Zend Library outside the webroot folder and call it with something like this:

$lib = realpath(dirname(basename(__FILE__)) . '/../../../lib');
set_include_path(get_include_path() . PATH_SEPARATOR . $lib);


$rootDir = dirname(dirname(__FILE__));
        define('ROOT_DIR', $rootDir);

        set_include_path(get_include_path()
            . PATH_SEPARATOR . ROOT_DIR . '/library/'
            . PATH_SEPARATOR . ROOT_DIR . '/app/models/'
        );

        include 'Zend/Loader.php';
        spl_autoload_register(array('Zend_Loader', 'autoload'));

        // Load configuration
        Zend_Registry::set('configSection', $configSection);
        $config = new Zend_Config(new Zend_Config_Ini(ROOT_DIR.'/application/config.ini', $configSection));
        Zend_Registry::set('config', $config);
困倦 2024-07-23 01:16:18

您可以通过使 Zend 库与您的多个项目共享来做到这一点,此 URL 将向您展示如何做到这一点

http://www.mauriciocuenca.com/blog/2009/03/two-or-more-zend-framework-projects-on -a-shared-host/

除此之外,在 wamp 中您可以配置 Vhost 以创建多个本地域:

http://mikebernat.com/blog/Adding_Virtual_Hosts_to_Apache_&_Wampserver

You can do that by making Zend Library shared with your multiple projects this Url will show you how can you do that

http://www.mauriciocuenca.com/blog/2009/03/two-or-more-zend-framework-projects-on-a-shared-host/

beside that in wamp you can configure Vhost to make multiple local domain:

http://mikebernat.com/blog/Adding_Virtual_Hosts_to_Apache_&_Wampserver

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文