How to Install the Chilkat PHP Extension on MAC OS X
The download contains the following files:
LICENSE.txt README.txt showExtDir.php test.php chilkat_9_5_0.php chilkat_9_5_0.so
2. Decompress and Extract to any Directory
gzip -dc chilkat-9.5.0-php-8.1-x86_64-macosx.tar.gz | tar -xof -
3. (If MacOS Catalina or later) Need Non-Default PHP to Install Extensions
MacOS Catalina (10.15) already comes with PHP located at /usr/bin/php, but it is not possible to install extensions because the extension directory is in a read-only directory tree. The easiest solution is to install PHP via brew and thus the extension directory would be located under /opt/homebrew/lib/php/pecl where it is possible to copy files. To install PHP via brew:
brew install firstname.lastname@example.org brew link php
For more information about installing PHP on MacOS Catalina, Google install php extension mac catalina
3. (If MacOS Version Older than Catalina) Copy chilkat_9_5_0.so to the PHP extensions directory.
To find the path of the PHP extensions directory, run the showExtDir.php script:
A typical extension directory path is /usr/local/lib/php/pecl/20160303. If PHP was installed via brew then a typical extension directory could be /opt/homebrew/lib/php/pecl/20210902. Many other possibilities exist.
It may be that the extensions directory does not yet exist. If so, create the directory. Make sure to use your PHP extensions directory, which may or may not be the same as what is shown here:
sudo mkdir /usr/local/lib/php/pecl/20160303
Now that the extensions directory exists, copy the chilkat shared library to it:
sudo cp chilkat_9_5_0.so /usr/local/lib/php/pecl/20160303
4. Edit php.ini.default to Automatically Load the Chilkat Extension
Find the location of the php.ini file with this command (run from the directory where Chilkat PHP was unpacked)
php phpinfo.php | grep php.ini
Another way of finding the location of php.ini is with this command:
You will need to be root to edit the php.ini.
Open the php.ini and locate the "Dynamic Extensions" section. Add the following line:
4. Run test.php to Verify
Run the test.php script to verify that the Chilkat extension is properly installed:
The test.php script encrypts and decrypts a string. If successful, the output will look like this:
SEb4OqIR4jmqYqIfUn8Inundvq0w7hXU55tgemIbl77bm28AqbIfG0OlC0wb4O3y The quick brown fox jumps over the lazy dog.
5. Use Chilkat in your PHP Scripts
To use Chilkat in your PHP scripts, include "chilkat_9_5_0.php" like this:
<?php include("chilkat_9_5_0.php"); ... ?>