I can see that GD library is for images. But I can't see differences between PECL and PEAR.
Both have authentication.
What are the main differences between two?
Why don't they combine them?
PECL stands for PHP Extension Community Library, it has extensions written in C, that can be loaded into PHP to provide additional functionality. You need to have administrator rights, a C compiler and associated toolchain to install those extensions.
PEAR is PHP Extension and Application Repository, it has libraries and code written IN php. Those you can simply download, install and include in your code.
So, yes they are similar, but yet so different :)
PECL is a repository of C extensions for PHP. Those extensions are usually installed via the pecl command, which is an alias for pear, with the default channel/repository set to pecl.php.net.
PEAR is multiple things:
The package installer (pear command) that is able to install packages from different channels (repositories), including pecl.php.net. Many consider composer the successor of the pear installer.
The package repository http://pear.php.net/packages.php with ~600 libraries. Many of them are composer-installable.
A PHP coding standard that is available with PHP_CodeSniffer.
pear is a php classes written in php
Whereas pecl is extensions which not written in php and need compiling .
PEAR as-such is not a coding standard. Instead PEAR "follows" a set coding standard that is encouraged within the PHP Community. This is however not the only coding standard that PHP users can follow, the ZF, for eg. recommends a slightly different standard.
PEAR is also a coding standard ;-)
php_codesniffer (install via $pear install php_codesniffer ) is a tool that will scan your code and hilight where it deviates from that or any other supported coding standard.
From my understanding, PHP has modules and frameworks, both being its libraries, external modules, called extensions, live in its PECL repository, while frameworks, called packages, live in its PEAR repository.
One can use PEAR packages within PHP code by simply sourcing the source code files, but PECL extensions should be installed on the system and enabled in configuration files to link to the interpreter.
Also, PEAR packages are written in PHP and are plain-text scripts, while PECL extensions are written in C/C++ and are compiled binaries in their consummable form.
Extensions as the name suggest extend PHP with something it doesn't offer by itself yet, while packages are just a collection of PHP code, ie. everything you can do with PHP proper.
This is parallel to Perl's PM modules and XS extensions.
That said, my view may not be 100% accurate, but that's how I could settle this in my mind :-)
Related
I'm trying to build a drupal webserver using composer, which I am told is the right way to do it.
The command I've used to install drupal is this:
composer create-project drupal-composer/drupal-project:8.x-dev --stability dev mysite --no-interaction
However, when I start my apache server I get a bunch of errors about missing libraries, functions, etc. I can resolve these by googling each one and installing the required php library - but isn't composer supposed to do this for me? According to the composer docs;
Composer is a tool for dependency management in PHP. It allows you to
declare the libraries your project depends on and it will manage
(install/update) them for you.
When I navigate to the mysite/vendor directory I see a bunch of drupal-related packages, but as far as I can tell these are only drupal dependencies, not php dependencies. Am I missing something here?
I think the confusion here comes from the word 'libraries'.
Composer is a tool for dependency management written in PHP.
PHP itself relies on a scripting engine (originally Zend, but there are alternatives like Facebook's HHVM, etc.), it works as a compiler and runtime engine and it needs 'libraries' - think of it as modules or extensions. These modules are mostly written in C, some in C++.
Having 'missing libraries' errors when Apache starts up does not mean Composer has missed any Drupal dependencies, it means PHP needs to be configured or rebuilt properly with the missing modules.
There are 3 types of modules (PHP's extensions membership):
Core modules that cannot be left out of a PHP binary with compilation options.
Core extension modules that are bundled with PHP core but not necessarily enabled.
External modules that are not bundled with PHP core. These modules are available from a repository called PECL (PHP Extension Community Library).
For example, if you were to speedup Drupal or any PHP applications by caching both PHP code and user variables, you would need some opcode like APC. That said, adding APC settings to php.ini would not work as is without the corresponding module being compiled with PHP.
I have an application which uses rabbit mq broker and I have consumers written on php and use this extension http://pecl.php.net/package/amqp. I would like to compile these consumers using hiphop but amqp extension is not supported in hiphop. So the question is could I compile PECL extensions into hiphop?
Thanks in advance
You would have to manually write a HipHop extension in C++ to interface with the extension's functionality. Most likely the original PHP extension is of little use, if it merely wraps a C library anyway. See the answers on this thread for an explanation of what the differences between HipHop and PHP extensions are: https://groups.google.com/group/hiphop-php-dev/browse_thread/thread/51184984d948a77b
I started the HHVM-AMQP project http://github.com/akalend/hhvm-amqp The base of the pecl/amqp is present, but exist the difference. See examples directory. It is developer version.
I'm trying to install PEAR, but I'm confused by the locations suggested.
I'm using Wampserver to run my PHP scripts, and I wanted to do unit tests. So I found PEAR.
I tried installing via the go-pear.bat file, but that didn't work.
I found out more about this here: http://blog.pear.php.net/2009/07/01/php-53-windows-and-pear/
So I downloaded the php file. The comments in the file suggest I
Put go-pear.php on your webserver,
where you would put your website
I find this a little strange. Still, I put it in the folder along with the other php files. Here's what I was presented with:
Maybe it is because I'm not very experienced with this, but I would initially believe I should put PEAR in a central location, using 1 pear install for all possible future projects.
Or is this the prefered configuration? And why?
Using a central location is the standard approach - it sometimes makes sense to have individual installs though, particularly if a speficic project requires older versions of some pear packages and would break if newer versions were installed.
Here's a pretty straightforward tutorial on how to set up PEAR on Wamp.
http://trac.symfony-project.org/wiki/HowToInstallPearOnWindowsWithWamp
You may have missed a few steps like adding PEAR to the PATH for Windows.
Also if you have a lot of problems with WAMPServer (I used to) there are alternatives like Zend Server Community Edition. http://www.zend.com/en/products/server-ce/index
After compiling PHP from source are the devel libraries still needed?
For example, I am building a newer version of PHP from source than is on our dev servers. I installed alot of [extension i.e. mysql, postgresql, curl, etc]-devel packages in order for the configure from the dev server setup to work. Do i still need these after php has compiled? For example could I make a distro and then distribute the PHP distro to another server without needing these devel dependencies?
I am a bit of a noob to this.
You don't need to ship the devel-libraries.
But my advice is to take some time and learn how the build system of your linux distribution works. And then build a new php package that can be installed by the package manager.
Take a look at how the "original" php packages were built for the distribution. Most likely you can simply copy and edit the existing rule file(s) and then make a new version of that package. This way you take advantage of the dependency mechanisms and the package manager will not remove/overwrite your version so easily when an update shows up in the "official" repositories.
I found a few related posts here but didn't get my answer. So posting again.
How would I install a PECL extension on windows? Say I want the PECL oAuth extension on Windows XP.
I know 2 methods, but none of them is working for me.
The site http://pecl4win.php.net/ is down for months. So I cant download the DLL. Is there any place we can download the DLLs from ?
running the command
pecl install oauth-0.99.9.tgz is throwing the error
The DSP oauth.dsp does not exist.
I tried with few other extensions also and getting the same error.
What am I missing here?
Releases can now be found here:
http://windows.php.net/downloads/pecl/releases/
If you need an extension not available there you might ask on the pecl-dev at lists.php.net mailing list.
I got what I am looking for in http://windows.php.net/downloads/pecl/releases/
Currently PECL for windows is in an odd reformation state. The reason being that I believe they are trying to provide VS2008 source versions. I would actually suggest using Zend Server for now until the windows half of the php group gets everything fixed up. Zend Server includes almost all of the extensions that you can find in PECL, and everything else, if you are lucky, you could find an compile yourself.
The PECL installer downloads the source code of the extension and tries to compile it with your local C compiler. The problem is that the whole process is designed for Unix systems, where a C compiler is available or can be easily installed. Setting an environment to compile C code under Windows is pretty complicate.
The ideal solution is getting a DLL file that someone already compiled. That's what the pcle4win site was for. However, there's currently no official repository to download PECL DLLs so you only have two alternatives:
Find an unofficial DLL somewhere in Google
Compile it yourself (another link) with Microsoft Visual Studio
It'd be cool that there was a DLL repository out there but I'm unaware of any.
The php source ships with a set of configuration scripts for windows (using windows script host) that mimics the autoconf tools as far as php is concerned. If you place the code for the extension in a directory under the /ext directory (where all the other extensions like bcmath, bzip, ... are located) you can let the buildconf-script create a makefile that includes the build rules for that (new) extension.
There's a step-by-step walk-through at http://wiki.php.net/internals/windows/stepbystepbuild which seems to be brief but feasible.
compiled oauth: http://windows.php.net/downloads/pecl/releases/oauth/
another pecl extension: http://windows.php.net/downloads/pecl/releases/