简体   繁体   English

PHP无法加载供应商文件夹:如何在我的服务器上安装composer?

[英]PHP failed to load vendor folder : How to install composer on my server?

Asked Here but no proper response. 在这里问,但没有适当的回应。

Hi, When I tried to use paypal sdk, and when I tried to submit the details, it is showing this error. 嗨,当我尝试使用paypal sdk并尝试提交详细信息时,它显示了此错误。

Fatal error: require(): Failed opening required '/home/wwwrapid/public_html/test/samples/vendor/paypal/paypal-merchant-sdk-php-4f570f5/lib/services/PayPalAPIInterfaceService/PayPalAPIInterfaceService.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/wwwrapid/public_html/test/merchant-sdk-php-master/samples/PPAutoloader.php on line 451

When I go through the folders path, I dont find any folder named 'vendor'. 当我通过文件夹路径时,找不到任何名为“ vendor”的文件夹。 I have been searching the solution for this for two days. 我已经为此寻找解决方案两天了。 Some sites say it's a composer error and installing composer solves the issue. 一些网站说这是一个作曲家错误,安装作曲家可以解决此问题。 and this is the code for that. 这是该代码。

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

My problem is I am not able to understand what they mean? 我的问题是我无法理解它们的意思? I don't even know where to add this code? 我什至不知道在哪里添加此代码? I mean in which file? 我的意思是在哪个文件中? How can that composer be installed on my site? 该作曲家如何安装在我的网站上?

If you're on Windows the easiest thing to do is download the Windows installer and use it. 如果您使用的是Windows,最简单的方法是下载Windows安装程序并使用它。

In order for Composer to install, though, you're going to need PHP installed. 但是,要安装Composer,您将需要安装PHP。 The easiest way to do this is to just configure a local server setup using WAMP or something similar. 最简单的方法是使用WAMP或类似方法配置本地服务器设置。 You'll need do that prior to installing Composer. 在安装Composer之前,您需要执行此操作。

Once all of that is done you'll be able to utilize Composer to manage PHP packages within your projects. 完成所有这些操作后,您将可以利用Composer在项目中管理PHP软件包。 It's really pretty awesome stuff, but it can be a little confusing if you've never worked with it before. 这确实是很棒的东西,但是如果您以前从未使用过它,可能会有些困惑。

Basically, once it's installed, you can just create a composer.json file at your project root. 基本上,一旦安装,您只需在项目根目录下创建composer.json文件。 This file is basically a config file that tells Composer what PHP packages you want to use (among other things.) 该文件基本上是一个配置文件,告诉Composer您想使用哪些PHP软件包(以及其他功能)。

For PayPal's SDK you could setup a composer.json file with nothing but this in it: 对于PayPal的SDK,您可以设置一个composer.json文件,仅包含以下内容:

"require": {
    "php": ">=5.3.0",
    "ext-curl": "*",
    "ext-json": "*",
    "paypal/rest-api-sdk-php" : "0.5.*"
}

Then, from the command line, you can browse to the project root (where the composer.json file is) and run "composer update". 然后,从命令行中,您可以浏览到项目根目录(composer.json文件所在的位置)并运行“ composer update”。

This would look at the composer.json file and download any/all packages that are required based on that line. 这将查看composer.json文件并根据该行下载所需的任何/所有软件包。 In this case it would be pulling in the PayPal REST API SDK, and then all of the samples that PayPal provides would work for you. 在这种情况下,它将引入PayPal REST API SDK,然后PayPal提供的所有示例都可以为您工作。

Composer is what creates that /vendor directory and sets up an autoloader for you. Composer会创建/ vendor目录并为您设置一个自动加载器。 Hope that helps. 希望能有所帮助。

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

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