PyroCMS - 在模块中加载自定义库
我正在编写一个 PyroCMS 模块,其中涉及图像上传和缩略图生成。我知道 codeigniter 有一个内置的图像处理类,能够制作缩略图,但我非常喜欢 phpThumb 的 ss 自适应调整大小功能。出于这个原因,我想尝试让 phpThumb 工作。
我已将 phpThumb 文件放置在 ./addons/shared_addons/modules/mymodule/libraries 中,
并且尝试使用以下内容加载:
$this->load->library('phpThumb/ThumbLib.inc.php');
我包含扩展名,因为 .inc.php 文件不是 .php 文件。 ?不管怎样,如果我保留扩展名或不保留扩展名,我都会收到此错误:
Class 'ThumbLib.inc.php' not found in .../htdocs/system/cms/libraries/MX/Loader.php on line 160
有人知道我做错了什么吗?
谢谢,艾德。
I'm writing a PyroCMS module which involves image upload and thumbnail generation. I'm aware codeigniter has a built in image manipulation class that's capable of making thumbnails, but I'm a big for of phpThumb'ss adaptive resize function. For this reason I'd like to try and get phpThumb working.
I've placed the phpThumb files in ./addons/shared_addons/modules/mymodule/libraries
and I'm trying to load using the following:
$this->load->library('phpThumb/ThumbLib.inc.php');
I'm including the extension because an .inc.php file is not a .php file right? Either way if I keep the extension or not I get this error:
Class 'ThumbLib.inc.php' not found in .../htdocs/system/cms/libraries/MX/Loader.php on line 160
Anyone know what I'm doing wrong?
Thanks, Ed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
加载程序命名约定可能更严格,因此您可能需要将文件重命名为“Thumblib.php”之类的名称,然后将您的类声明为
class Thumblib {
。您可能还需要检查该库是否与适合在 CI 中使用的任何内容发生冲突。另外,我认为只要您从与库位于同一模块文件夹树中的控制器加载库,加载线应该类似于:
或者如果不是:
祝你好运。
The loader naming conventions are probably stricter, so you may need to rename your file to something like 'Thumblib.php' and then declare your class as so
class Thumblib {
. You may also need to check the library doesn't conflict with anything as is suitable to use in CI.Also, I think as long as you are loading the library from a controller in the same module folder tree as the library, the load line should be something like:
Or if not:
Good luck.
这是 CodeIgniter 问题,而不是 PyroCMS 问题。
简单的解决方案:
请记住,这只是 PHP。您不需要针对所有事情使用特殊方法!
This is a CodeIgniter question, not a PyroCMS question.
Simple solution:
Remember guys it's just PHP. You don't need a special method for everything!