PHP - 扩展主场迎战主场迎战图书馆类 - 时间和原因 [英] PHP - Extension vs. Library vs. Class - when and why

查看:128
本文介绍了PHP - 扩展主场迎战主场迎战图书馆类 - 时间和原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图完成一项任务,原来,code,我需要被打包为一个PHP的扩展,它根据什么我已经告诉意味着我必须有root权限来安装它(我在共享主机所以这是有点问题的。

I'm trying to accomplish a task and turns out that the code I need is packaged as a PHP extension, which according to what I've been told means I have to have root access to install it (I'm on shared hosting so that's a bit of a problem.

我稍后会解决这个问题,但现在我想明白一个扩展,图书馆和类之间的区别。它是一个多包装可能被覆盖,并重新包装以不同的方式,还是有它背后一个有效的建筑推理的事情吗?

I'll solve this problem later, but for now I'm trying to understand the difference between an extension, a library, and a class. Is it more of a packaging thing that could be overridden and repackaged a different way, or is there a valid architectural reasoning behind it?

还推出了自己的code时,是什么让你决定释放的库与类与延伸?或者你有任何听起来更好走?

Also when releasing your own code, what makes you decide to release as library vs. class vs. extension? or do you go with whichever sounds better?

在此先感谢。

P.S。如果你一定要知道我说的是哪个扩展,这是 Libpuzzle ,但是这真的旁边这一点,我的问题是更普遍。

P.S. If you must know which extension I'm talking about, it's Libpuzzle, but that's really beside the point, my question is more general.

推荐答案

扩展是低层次的。通常用C / C ++和汇编成native- code共享库,它们与Zend引擎直接交互。它的优点和缺点,是速度和更多的控制主要优点;而主要缺点 - 它们是难以安装,并要求汇编(这需要一个编译器和PHP头);这不是真的,他们需要root权限,但 - 你只需要使用自定义的php.ini(或 DL(能力) 功能,但我看到他们去precated由于某种原因)。

Extensions are low-level. Usually written in C/C++, and compiled into native-code shared libraries, they interact with the Zend Engine directly. It has pros and cons, main advantages being the speed and more control; and main disadvantages - they are harder to install, and require compilation (and that requires a compiler and PHP headers); it's not true they require root access though - you only need ability to use custom php.ini (or dl() function, but I see they deprecated it for some reason).

库/类是高层次,跨preTED。如果你不知道,如果你需要写的扩展,那么你可能不知道。什么类 - 了解 OOP 。图书馆是code的可重用集合(最常用的功能/班的形式)。

Libraries/classes are high-level and interpreted. If you don't know if you need to write extension, then you probably don't. About what classes are - read about OOP. A library is a reusable collection of code (most commonly in form of functions/classes).

这篇关于PHP - 扩展主场迎战主场迎战图书馆类 - 时间和原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆