将Web应用程序(ZF2)转换为PHAR

问题描述 投票:5回答:1

我知道如何将php文件转换为phar文件。

$phar = new PHAR('app.phar');
$phar->addFile('file1.php');
$phar->addFile('file2.php');

我认为它只对将POPO转换为PHAR非常有用。

我的问题

是否可以将整个Zend框架2 Web应用程序转换为PHAR文件?如果是,那怎么样?

(要么)

如何将Zend framework2 Web应用程序打包到一个包中? (.zpk(zend studio包文件)文件格式除外)


Updated: creating Phar from entire application

创建-Frkphp

$basePath = /path/to/;
$path = /path/to/application;  
$phar = new Phar ('project.phar');    
$phar->buildFromIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)), $basePath);
$phar->setStub("<?php 
    Phar::webPhar('project', 'public/index.php');
       include 'phar://project/public/index.php';
       __HALT_COMPILER();
    ?>");

的index.php

<?php
include 'project.phar';
?>

题:

当我运行index.php时,它不会重定向到实际的public / index.php文件,而是在浏览器上显示空白页面。我该如何解决这个问题?

提前致谢

php zend-framework zend-framework2 phar
1个回答
5
投票

我将phorkie部署为.phar文件。

有一些事情需要考虑:

  1. 打包.phar中的所有文件 - php和静态资产文件(js,css,png,jpg)。 I use phing这样做。不要忘记依赖项。
  2. 您需要一个运行Phar::webPhar()的存根文件,它负责发送HTTP标头
  3. 编写自己的.htaccess重写规则解释器,因为Phar::webPhar()不会自行解决好路径问题。我did that already
  4. 手动处理发送静态文件的缓存标头
  5. 希望您(或您的用户)不会遇到其中一个Phar::webPhar错误: Symlinked files No HEAD, PUT or DELETE support Redirection loop with FPM(已在git中修复)
  6. 希望你的用户的web server handles .phar files(它不会; neither Debian nor Fedora发货那个配置)
  7. 希望用户的Web服务器正确配置为处理附加.pharPATH_INFO)的/path/to/file.phar/foo/bar.png文件,就像在http://p.cweiske.de/122中一样

.phar开始运行phorkie让我度过了两个星期的晚上。现在它基本上工作了它仍然不是一个drop-phar-and-play解决方案,因为web服务器的默认配置与.phar不相称。

© www.soinside.com 2019 - 2024. All rights reserved.