简体   繁体   English

如何在webspace上使用没有composer的PHP库?

[英]How to user PHP library without composer on webspace?

php 5.4 PHP 5.4

Library apai-io 图书馆apai-io

This lib is created with composer. 这个lib是用composer创建的。 But I cannot use composer on my webspace. 但是我不能在我的网站空间上使用composer。

I googled it and the answer was to include an autoloader function and register it with spl_autoload_register. 我用谷歌搜索它,答案是包含一个自动加载器功能并将其注册到spl_autoload_register。

I have tried not been able to get anything to work with autoload funtions. 我试过无法使用自动加载功能。

I don't know if I had to replace namespace and use from scripts or replace them with spl_autoload_register or both. 我不知道是否必须替换命名空间并使用脚本或用spl_autoload_register或两者替换它们。

namespace ApaiIO;

use ApaiIO\Configuration\ConfigurationInterface; 
use ApaiIO\Operations\OperationInterface;
use ApaiIO\Request\RequestFactory;
use ApaiIO\ResponseTransformer\ResponseTransformerFactory;

Can somebody explain me (maybe with source code) what I need to do to get the library running? 有人可以解释我(可能有源代码)我需要做什么来运行库?

(UPDATE) (UPDATE)

  • dowloaded XAMPP & Composer 下载了XAMPP和Composer

  • added depency to composer.json 为composer.json添加了依赖项

  • run composer install --> lib was added 运行composer install - > lib已添加

  • uploaded the whole vendor folder 上传了整个供应商文件夹

  • wanted to start example of lib 想要开始lib的例子

-->error: - >错误:

You must set up the project dependencies, run the following commands: curl -s http://getcomposer.org/installer | php php composer.phar install 您必须设置项目依赖项,运行以下命令: curl -s http://getcomposer.org/installer | php php composer.phar install curl -s http://getcomposer.org/installer | php php composer.phar install

Question: Do I have to add the autoload.php in folder vendor to any script? 问题:我是否必须将文件夹供应商中的autoload.php添加到任何脚本中?

将以下代码添加到您的php文件中

require_once "vendor/autoload.php";

就像每个人在主帖上的评论中所说的那样,在你的本地机器上安装你的库,只需将作曲家为你制作的/ vendor目录复制到你的生产服务器上。

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

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