我正在使用cakephp-3.0。
在插件的一个组件中,我想在plugins webroot中加载一个XML文件。
simplexml_load_file('RangeMessage.xml')文件找不到。使用
debug(realpath(''));说,实际的目录是/path/to/app/webroot。然而,我的xml-文件是在/path/to/app/plugins/myPlugin/webroot中的,所以我如何在不使用绝对路径的情况下找到该文件?
发布于 2015-05-29 12:27:23
您可以使用Plugin::path()检索插件的绝对路径,因此不必硬编码它。
Plugin::path('YourPlugin') . 'webroot' . DS . 'RangeMessage.xml'另见API > Cake\Core\Plugin::path()
https://stackoverflow.com/questions/30529133
复制相似问题