php - 在 wordpress 主题中使用作曲家和自动加载,“需要打开失败”
问题描述
所以我已经通过 composer 为我的主题安装了 createend-php (我正在尝试学习如何使用它)但无法进入下一阶段。
我可以在这里看到 API -
/wp-content/themes/wonkhe2-theme/vendor/campaign-monitor/createsend-php/
作曲家文件对我来说似乎是正确的-
"require": {
"php": ">=5.4.0",
"composer/installers": "~1.0",
"campaignmonitor/createsend-php": ">=6.0"
}
在 /wp-content/themes/wonkhe2-theme/templates/content-signup-cm.php 我添加了
require_once 'csrest_campaigns.php'
这又回来了
Fatal error: require_once(): Failed opening required 'csrest_campaigns.php' (include_path='.:/Applications/MAMP/bin/php/php7.2.7/lib/php') in /wp-content/themes/wonkhe2-theme/templates/content-signup-cm.php on line 5
require_once 路径应该不同吗?我认为自动加载器会设置路径和命名空间。
使用作曲家对我来说是新的,如果我有误解,我们深表歉意,但感谢任何帮助。
解决方案
您不应该要求作曲家安装单独的课程。相反,就在代码的开头:
require_once 'vendor/autoload.php';
然后你就可以开始使用对象了;
use Some\Class\Or\Other;
$object = new Other();
推荐阅读
- git - 错误“致命:无法从远程存储库读取”git push - ssh 密钥
- c++ - 在 C++ 中合并排序意外输出
- python - 我很难理解伪代码
- d3.js - 从强制边缘捆绑创建路径不与 D3 中的节点位置对齐
- python - 用python自动打开微软商店应用程序/游戏?
- javascript - 在精美图库中的图像上显示文本时出现问题
- r - R 工作室 youtubecaption
- mysql - MySql 数据库连接问题
- python-3.x - 无法使用 pandas 将对象 dtype 转换为 mm:ss:ms 格式的持续时间
- javascript - IE 将 window.closed 显示为 true,即使窗口处于打开状态