PyroCMS - 在模块中加载自定义库

发布于 2025-01-06 08:59:02 字数 549 浏览 0 评论 0原文

我正在编写一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

路还长,别太狂 2025-01-13 08:59:02

加载程序命名约定可能更严格,因此您可能需要将文件重命名为“Thumblib.php”之类的名称,然后将您的类声明为 class Thumblib {。您可能还需要检查该库是否与适合在 CI 中使用的任何内容发生冲突。

另外,我认为只要您从与库位于同一模块文件夹树中的控制器加载库,加载线应该类似于:

$this->load->library('Thumblib');

或者如果不是:

$this->load->library('othermodule/Thumblib');

祝你好运。

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:

$this->load->library('Thumblib');

Or if not:

$this->load->library('othermodule/Thumblib');

Good luck.

这是 CodeIgniter 问题,而不是 PyroCMS 问题。

简单的解决方案:

 include 'whatever/the/hell/you.like.php';

请记住,这只是 PHP。您不需要针对所有事情使用特殊方法!

This is a CodeIgniter question, not a PyroCMS question.

Simple solution:

 include 'whatever/the/hell/you.like.php';

Remember guys it's just PHP. You don't need a special method for everything!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文