如何在没有作曲家的情况下在网络空间上使用 PHP 库?
How to user PHP library without composer on webspace?
php 5.4
这个库是用 composer 创建的。但是我不能在我的空间上使用作曲家。
我用谷歌搜索了一下,答案是包含一个自动加载器功能并用 spl_autoload_register 注册它。
我试过无法使用自动加载功能。
我不知道我是否必须替换名称空间并从脚本中使用,或者用 spl_autoload_register
或两者替换它们。
namespace ApaiIO;
use ApaiIO\Configuration\ConfigurationInterface;
use ApaiIO\Operations\OperationInterface;
use ApaiIO\Request\RequestFactory;
use ApaiIO\ResponseTransformer\ResponseTransformerFactory;
有人可以向我解释一下(也许是源代码)我需要做什么才能获得库 运行ning 吗?
(更新)
已下载 XAMPP & 作曲家
添加了对 composer.json
的依赖
运行 作曲家安装
--> 添加了库
上传了整个供应商文件夹
想要启动 lib 示例
-->错误:
You must set up the project dependencies, run the following commands: curl -s http://getcomposer.org/installer | php php composer.phar install
问题:
我是否必须将文件夹 vendor 中的 autoload.php 添加到任何脚本?
就像每个人在主评论中所说的 post,在本地机器上安装你的库,然后将 composer 为你制作的 /vendor 目录复制到你的生产服务器。
将以下代码添加到您的 php 文件
require_once "vendor/autoload.php";
php 5.4
这个库是用 composer 创建的。但是我不能在我的空间上使用作曲家。
我用谷歌搜索了一下,答案是包含一个自动加载器功能并用 spl_autoload_register 注册它。
我试过无法使用自动加载功能。
我不知道我是否必须替换名称空间并从脚本中使用,或者用 spl_autoload_register
或两者替换它们。
namespace ApaiIO;
use ApaiIO\Configuration\ConfigurationInterface;
use ApaiIO\Operations\OperationInterface;
use ApaiIO\Request\RequestFactory;
use ApaiIO\ResponseTransformer\ResponseTransformerFactory;
有人可以向我解释一下(也许是源代码)我需要做什么才能获得库 运行ning 吗?
(更新)
已下载 XAMPP & 作曲家
添加了对 composer.json
的依赖运行 作曲家安装 --> 添加了库
上传了整个供应商文件夹
想要启动 lib 示例
-->错误:
You must set up the project dependencies, run the following commands:
curl -s http://getcomposer.org/installer | php php composer.phar install
问题: 我是否必须将文件夹 vendor 中的 autoload.php 添加到任何脚本?
就像每个人在主评论中所说的 post,在本地机器上安装你的库,然后将 composer 为你制作的 /vendor 目录复制到你的生产服务器。
将以下代码添加到您的 php 文件
require_once "vendor/autoload.php";