在 Windows 中的 XAMPP 上安装 Zend Framework 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11562617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:42:26  来源:igfitidea点击:

Installing Zend Framework 2 on XAMPP in Windows

windowsxamppzend-framework2

提问by 125369

I know this question may have appeared few times here and in the internet. But still I feel it is not clear for somebody who wanted to enter into the world of frameworks. I have followed these links Rob Allens Tutorial, ZF Quick Tutorial.

我知道这个问题可能在这里和互联网上出现过几次。但是我仍然觉得对于想要进入框架世界的人来说还不清楚。我遵循了这些链接Rob Allens 教程ZF 快速教程

But some how I feel it is not quite clear with the installation part. I have a windows system basically Vista with the newest version of XAMPP installed. I have downloaded the latest version of ZFSkeletonApplication from this link ZFSkeletonApp, extracted the skeleton contents, renamed the folder to zendframework and moved it to xampp folder i.e now ZF skeleton is in c:\xampp\zendframework.

但是安装部分我感觉有些不太清楚。我有一个 Windows 系统,基本上是 Vista,安装了最新版本的 XAMPP。我已经从此链接ZFSkeletonApp下载了最新版本的 ZFSkeletonApplication ,提取了骨架内容,将文件夹重命名为 zendframework 并将其移动到 xampp 文件夹,即现在 ZF 骨架在 c:\xampp\zendframework 中。

So until here everything seems clear and easy, from here I am some how lost with the configurations. Can some one elaborate the things from here how to install the Zf and make it work, like changes in the include paths, .htaccess files and so on. Please do remember that I have windows with XAMPP on it. If some one can guide me exactly for this set up, it would be helpful.

所以直到这里一切都变得清晰而简单,从这里我对配置失去了一些了解。有人可以从这里详细说明如何安装 Zf 并使其工作,例如更改包含路径、.htaccess 文件等。请记住,我有带有 XAMPP 的窗口。如果有人可以准确地指导我进行此设置,那将很有帮助。

P.S. It would be good if one can provide info about the changes which I need to make with examples consisting of paths, so that I am not lost, for example like you can find .htaccess file here(ex pathname), changes in .htaccess file should be so and so.

PS 如果可以提供有关我需要使用由路径组成的示例进行的更改的信息,那将是很好的,这样我就不会迷路,例如,您可以在这里找到 .htaccess 文件(ex pathname),.htaccess 中的更改文件应该是某某。

Thanks

谢谢

采纳答案by Sam

For future references, i also made a big post on how to install ZF2 on a windows xampp environment right here Install ZF2 on Windows Xampp

为了将来参考,我还发表了一篇关于如何在 windows xampp 环境中安装 ZF2 的重要帖子,就在此处Install ZF2 on Windows Xampp

OK, i have done this on multiple systems now. For a home system the following steps work quite well:

好的,我现在已经在多个系统上完成了这项工作。对于家庭系统,以下步骤非常有效:

  • Download msysGitand install it to any directory
  • Run the git-cmd.bat from the msysGit-Folder
  • Move into the directory you want i.e. C:\xampp\htdocs\(this is done via cd dirnameor cd ..to go up a level, change partition with D:and hit enter)
  • 下载msysGit并安装到任意目录
  • 从 msysGit-Folder 运行 git-cmd.bat
  • 移动到你想要的目录,即C:\xampp\htdocs\(这是通过cd dirnamecd ..上一级,更改分区D:并按回车键完成的)

Run the following command. The <OptionalFolderName>would be the name of a Sub-Directory of htdocs, if you skip this, the folder will get named ZendSkeletonApplication

运行以下命令。该<OptionalFolderName>会的一个子目录的名称htdocs,如果你跳过这一点,该文件夹将得到命名ZendSkeletonApplication

git clone git://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>

Possible Trouble Scenario(fatal:unable to connect to github.com)

可能的问题场景致命:无法连接到 github.com

Once again at workplaces, pretty often the default port (9418) for the git-protocol is blocked. If this is the case for you, then you should try one of the following Commands

再一次在工作场所,git 协议的默认端口 (9418) 经常被阻止。如果您是这种情况,那么您应该尝试以下命令之一

git clone https://github.com/zendframework/ZendSkeletonApplication.git <OptionalFolderName>
git clone [email protected]:zendframework/ZendSkeletonApplication.git <OptionalFolderName>

Now you are not done yet. The skeleton Application is installed, but the framework is still missing, here some people might run into the first problems, but this actually is quite easy.

现在你还没有完成。骨架应用程序安装好了,但是框架还没有,这里有些人可能会遇到第一个问题,但这实际上很容易。

We're still at the command line interface

我们仍然在命令行界面

  • cd <OptionalFolderName>or cd ZendSkeletonApplicationdepending on what you did earlier
  • php composer.phar self-update
  • php composer.phar install(this might take a while)
  • cd <OptionalFolderName>或者cd ZendSkeletonApplication取决于你之前做了什么
  • php composer.phar self-update
  • php composer.phar install(这可能需要一段时间)

So, this is the part where lots of things can happen. I have two scenarios happened to me:

所以,这是可能发生很多事情的部分。我有两种情况发生在我身上:

Scenario #1No directory write permissions

场景 #1没有目录写入权限

This is easily handled by running the command line interface with administrator privileges

这可以通过以管理员权限运行命令行界面轻松处理

Scenario #2Working behind a router (i.e. at work)

场景 #2在路由器后面工作(即在工作中)

Personally i didn't have to do much to get this working, but the line might change depending on your proxy. Personally i did the following at the command line interface

就我个人而言,我不需要做太多事情来让这个工作,但线路可能会根据您的代理而改变。我个人在命令行界面执行了以下操作

  • SET HTTP_PROXY=http://proxy.domain.tld:8080you might also be good with
  • SET HTTP_PROXY=proxy.domain.tld:8080don't ask me why, but i needed the http://
  • SET HTTP_PROXY=http://proxy.domain.tld:8080你可能也很擅长
  • SET HTTP_PROXY=proxy.domain.tld:8080不要问我为什么,但我需要 http://

With all those done, you should have an almost running ZendSkeletonApplication. The other part is how to set up your virtual host, but i won't go into detail on this, as that's even ZF1 Stuff and everyone should be familiar with that by now, if not, there's good resources to learnout there.

完成所有这些后,您应该有一个几乎可以运行的 ZendSkeletonApplication。另一部分是如何设置您的虚拟主机,但我不会详细介绍这一点,因为即使是 ZF1 Stuff,现在每个人都应该熟悉它,如果没有,那里有很好的资源可供学习

I hope i could be of help to you.

我希望我能对你有所帮助。

回答by Jaime Marcelo Valasek

Setbacks have to install in Windows, but I ended up finding a solution. From ZF2 to install on windows via git, for this is the only use that simulates msysGit git linux on windows, for it is only access the tutorial: http://zf2.com.br/tutoriais/post/instalando-o-git-no-windows-para-fazer-a-instalacao-do-zf2-somente-no-comando-do-windows-via-composer

挫折必须安装在 Windows 中,但我最终找到了解决方案。从 ZF2 到通过 git 安装在 windows 上,因为这是在 windows 上模拟 msysGit git linux 的唯一用途,因为它只能访问教程:http: //zf2.com.br/tutoriais/post/instalando-o-git -no-windows-para-fazer-a-instalacao-do-zf2-somente-no-comando-do-windows-via-composer

回答by Guru A S

Since I had lot dependency extension problems (mostly .dll files) with old version of XAMPP, so first thing I did was made sure I uninstall all previous versions of PHP already present on my system as well as old XAMPP. Then installed latest XAMPP v3.2.2 (using latest XAMPP 3.2.2-32-bit on Win-7-64-bit). Then followed installation steps in XAMPP Documentation under title Start a New Zend Framework 2 Project.

由于旧版本的 XAMPP 有很多依赖项扩展问题(主要是 .dll 文件),所以我做的第一件事是确保卸载系统上已经存在的所有以前版本的 PHP 以及旧的 XAMPP。然后安装最新的 XAMPP v3.2.2(在 Win-7-64 位上使用最新的 XAMPP 3.2.2-32 位)。然后按照标题Start a New Zend Framework 2 Project下的 XAMPP 文档中的安装步骤进行操作。

I had issues while installing composer also with old-XAMPP, but somehow those errors didn't appear during composer installation this time. And, I successfully installed ZEND till I typed http://localhost:8081/myapp/(I renamed my ZendSkeletonApplictionfolder as myappas per documentation) into my browser to access the same and met the error which said:

我在使用旧的 XAMPP 安装 composer 时也遇到了问题,但不知何故,这次在 composer 安装过程中没有出现这些错误。而且,我成功安装了 ZEND,直到我在浏览器中输入http://localhost:8081/myapp/(我根据文档重命名了我的ZendSkeletonAppliction文件夹myapp)以访问相同的内容并遇到了错误:

Fatal error: Uncaught RuntimeException: Unable to load ZF2. Run php composer.phar install or define a ZF2_PATH environment variable. in C:\xampp\apps\myapp\htdocs\init_autoloader.php:51
Stack trace:
 #0 C:\xampp\apps\myapp\htdocs\public\index.php(18): require()
 #1 {main} thrown in C:\xampp\apps\myapp\htdocs\init_autoloader.php on line 51

Composer.pharwas not even present the first time I downloaded ZendSkeletonApplication‐master.zipfrom Github (there was only composer.jsonand composer.lockfiles present). Anyhow I didn't need them since I followed XAMPP Doc which doesn't call composer.pharin command line:

Composer.phar甚至没有出现在我第一次下载ZendSkeletonApplication‐master.zip从GitHub(当时只有composer.jsoncomposer.lock文件存在)。无论如何,我不需要它们,因为我遵循了不在composer.phar命令行中调用的 XAMPP Doc :

composer create‐project ‐s dev zendframework/skeleton‐application path/to/install

I am not that tech-savvy to know how to 'define a ZF2_PATHenvironment variable' correctly, so I wasted time looking for solution online, couldn't find any (which is when I stumbled on this forum which also turned out not to have a solution for my query). In the end, in a fit of depression and anxiety, serendipity happened. All I did was as per XAMPP's ZEND documentation I right-clicked inside C:\xampp\apps\myapp\htdocsfolder and clicked 'Composer Install' which reinstalled the Zend files from cache. Then refreshed http://localhost:8081/myapp/and the Zend intro page appeared.

我不是那么精通技术,不知道如何ZF2_PATH正确“定义环境变量”,所以我浪费时间在网上寻找解决方案,找不到任何解决方案(这是我偶然发现这个论坛的时候,结果也没有我的查询的解决方案)。最后,在一阵压抑和焦虑中,意外发生了。我所做的只是按照 XAMPP 的 ZEND 文档,我在C:\xampp\apps\myapp\htdocs文件夹内右键单击并单击“ Composer Install”,这会从缓存中重新安装 Zend 文件。然后刷新http://localhost:8081/myapp/并出现 Zend 介绍页面。

回答by Theo Walcott

I just did it like that:

我就是这样做的:

D:\web_dev\zendapp>C:\PHP\php.exe composer.phar self-update

it worked perfectly

它工作得很好