简体   繁体   English

如何使用Composer在单个phar文件中部署Web应用程序?

[英]How to deploy a webapplication in a single phar file with composer?

I intend to use single phar file with digital signature to deploy a web application. 我打算使用带有数字签名的单个phar文件来部署Web应用程序。 Combined this with event sourcing would make me very easy to follow release early, release often philosophy... 将此与事件来源相结合,将使我非常容易地及早关注发布,经常发布哲学...

I am using composer as package manager. 我正在使用composer作为程序包管理器。 What I am uncertain: 我不确定的是:

  • How to pack the vendors with my application into a single phar? 如何将供应商和我的应用程序打包到一个单独的文件中?
    I am not sure how composer installs a vendor, but I think it can install them as phar files as well. 我不确定作曲家如何安装供应商,但我认为它也可以将其安装为phar文件。 I found almost nothing about phar-s packed into other phars. 我几乎没发现关于包装在其他相中的法耳的信息。
  • Is composer's autoloader prepared to do that, or I have to do some modifications? 作曲家的自动加载器是否准备好执行此操作,或者我必须进行一些修改?
  • Do I have to install composer on the server? 我必须在服务器上安装composer吗? (I have no CLI, and I have no rights to do that. Bad for me, yes.) (我没有CLI,也没有这样做的权利。是的,对我来说是不好的。)
  • How can I filter out automatically the tests and documentations of my application and its dependencies. 如何自动筛选出应用程序及其依赖项的测试和文档。 (I want to have a small release package.) (我想要一个小的发布包。)

To answer some of your questions: 要回答您的一些问题:

  1. Composer does not install .phar files as the dependencies. Composer不会将.phar文件安装为依赖项。 In fact, those common packages that do come as .phar file (namely PHPUnit) do offer .phar as an alternative to using Composer, which is mutually exclusive. 实际上,那些作为.phar文件(即PHPUnit)提供的常用软件包的确提供了.phar作为使用Composer的替代方法,Composer是互斥的。 So you'd simply run composer install , get a directory tree of your own files and vendor files, and can then add these all into the .phar file you are about to create. 因此,您只需运行composer install ,获取您自己的文件和供应商文件的目录树,然后就可以将它们全部添加到您要创建的.phar文件中。
  2. Composer autoloader does use __DIR__ to know where it is, and where other files are relative from this constant. Composer自动加载器的确使用__DIR__来知道它在哪里,以及该常量相对其他文件在哪里。 This should be compatible with .phar files. 这应该与.phar文件兼容。
  3. You have to install Composer on the machine you intend to create the .phar files on. 您必须在要在其上创建.phar文件的计算机上安装Composer。
  4. Filtering unwanted files is the task of your build script that creates the .phar files. 筛选不需要的文件是创建.phar文件的构建脚本的任务。 It is not the task of Composer. 这不是Composer的任务。

Note that there are already libraries that help you creating .phar files. 请注意,已经有可以帮助您创建.phar文件的库。 Have a look at kherge/box , for example. 例如,看看kherge / box

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM