InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
PHP
Installing PECL Packages in PHP
PHP

Installing PECL Packages in PHP

InfinityCoder December 27, 2016

You want to install a PECL package; this builds a PHP extension written in C to use inside PHP.

Make sure you have all the necessary extension libraries and then use the bundled installer pecl:

1
% pecl install mailparse

To use the extension from PHP, add the appropriate line to your php.ini file:

1
extension=mailparse.so

The frontend process for installing PECL packages is just like installing PEAR packages for code written in PHP. However, the behind-the-scenes tasks are very different.

Be cause PECL extensions are written in C, the installer needs to compile the extension and configure it to work with the installed version of PHP.

As a result, at present, you can build PECL packages on Unix machines if you have the necessary development
tools installed.
Unlike PHP-based PEAR packages, PECL extensions don’t automatically inform you when you lack a library necessary to compile the extension.

Instead, you are responsible for correctly preinstalling these files. If you are having trouble getting a PECL extension
to build, check the README file and the other documentation that comes with the package.

The installer puts these files inside the docs directory under your PEAR hierarchy.
When you install a PECL extension, the pecl command downloads the distribution file, extracts it, runs phpize to configure the extension for the version of PHP installed on the machine, and then makes and installs the extension.

It may also prompt you for the location of libraries:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
% pecl install memcached
 
downloading memcached-2.1.0.tgz ...
Starting to download memcached-2.1.0.tgz (39,095 bytes)
..........done: 39,095 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version:       20100412
Zend Module Api No:    20100525
Zend Extension Api No: 220100525
 
...
 
Build complete.
 
...
 
install ok: channel://pecl.php.net/memcached-2.1.0
You should add "extension=memoize.so" to php.ini

PECL extensions are stored in different places than PEAR packages written in PHP. If you want to run pecl, you must be able to write inside the PHP extensions directory.
Because of this, you may want to install these packages while running as the same user you used to install PHP.

Also, check the execute permissions of these files; because most PEAR files aren’t executable, your umask may not provide those executable files with the correct set of permissions.
If you’re running PHP and PECL in a Windows environment, you may prefer to download precompiled DLLs for the PECL extensions you need by browsing the extension’s page.

Share
Tweet
Email
Prev Article

Related Articles

Fetching a URL with Arbitrary Headers in PHP
You want to retrieve a URL that requires specific headers …

Fetching a URL with Arbitrary Headers in PHP

Finding the Difference of Two Dates in PHP
    You want to find the elapsed time between …

Finding the Difference of Two Dates in PHP

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap