Installing php-module using port on osx lion - xcode

I am trying install php5-intl on my osx lion.
I did install also Xcode.
When I run the command to install the module I get the following message.
> sudo port install php5-intl
---> Computing dependencies for php5-intl
---> Cleaning php5-intl
> locate *intl*|grep so\$
/opt/local/lib/php/extensions/no-debug-non-zts-20090626/intl.so
> sudo apachectl restart
My question is:
Is the php5-intl module installed and ready to be used in my apache?
P.S.:
If I look to my phpinfo() I don't see any reference to php-intl. Is it normal?
If I run
> php -m | grep intl
PHP Warning: Module 'intl' already loaded in Unknown on line 0
intl
Then If I try to use it in Synfony2 I get the following error:
The Symfony\Component\Locale\Stub\StubLocale::getDisplayLanguage() is not implemented.
Please install the 'intl' extension for full localisation capabilities
If I look to my phpinfo, no trace of php5-intl.

If it's not listed in phpinfo() (or php -m on the command line) then no, the module isn't enabled.
If I were you I'd get this working on the command line first, since if I remember right Port uses it's own version of PHP (and Apache?), which could cause confusion.
You'll need to enable the module with extension=php5-intl.so in your php.ini file, after adding that php -m should include intl, and you know the extension is working on the command line.
Edit:
PHP Warning: Module 'intl' already loaded in Unknown on line 0
This sounds like you maybe have the module enabled twice, though I don't think that's necessarily your problem.
Try running a simple command line script that calls an intl function, it sounds to me like it's enabled for the command line but not for apache.

Related

fatal error: 'unicode/usprep.h' file not found when installing php mongodb

I'm trying to run
sudo /Applications/XAMPP/bin/pecl install mongodb
and i got
fatal error: 'unicode/usprep.h' file not found
I've found solutions using brew but on my mac I use mac ports, is there is a solution using port
Here is what I finally did, I've manually installed the php extension following those steps:
1.I've downloaded mongodb php source from
https://pecl.php.net/package/mongodb
2.Uncompress the tgz and go into the directory
3./Applications/XAMPP/xamppfiles/bin/phpize
4../configure --with-mongodb-sasl=no
5.make all
6.sudo make install
7.add extension=mongodb.so at the end of php.ini
et voila

Installation of Xdebug on MacOS Catalina 10.15

I tried to install Xdebug on OS X 10.15 and run into following problem:
/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found
I tried to fix the problem like described here: Installing xdebug on MacOs Mojave - 'php.h' file not found
Unfortunately the header files cannot be found in this directory: /Library/Developer/CommandLineTools/Packages
Any ideas where I can get the current header files for OS X 10.15?
Update
For anyone that just want xdebug support on MacOS, most of the instructions in this answer are not necessary when using the built-in version of PHP. Before doing anything, you should check if xdebug.so already exists in /usr/lib/php/extensions/no-debug-non-zts-20180731/, which should be there by default. If so, you can skip to the Enabled support in PHP portion of this answer.
Using Homebrew is also an acceptable solution for you (and can also prevent other issues).
For anyone else looking to actually build binaries on MacOS and get the header error, the full answer is for you. It also answer OP question directly. Note building xdebug from source code and actually trying to use that version of xdebug.so with the build-in PHP should end up in a "code signature" error. As described here and here, the only real solution would be to compile and use you own instance of PHP instead of the built-in one. In any situation, using Homebrew would be easier.
tl;dr
Apple decided to remove headers file in /usr/include and the macOS_SDK_headers_for_macOS_10.14.pkg package. To install Xdebug, you'll have to manually compile Xdebug with the correct reference in both phpize and make.
For more details, I wrote a blog article about the issue and the solution
Original Answer:
Long story short, Apple decided to nuke /usr/include in MacOS Catalina, which has been the default location for C header file for ever in UNIX systems. Trying to install through PEAR / PECL will return an error as the compiler will look for necessary headers file in /usr/include. So the solution is to compile Xdebug manually, manually specifying the actual location of the header files, which are still provided by Xcode, just at a different location.
First, make sure Xcode is installed, including the command line tools. The following command will display the location of the default SDK :
$ xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
The header you'll want (php.h) will then be in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/main.
Getting source
Let's compile 2.7.2, getting the source code from git. Alternatively, you can download the source from Xdebug site.
git clone https://github.com/xdebug/xdebug.git
cd xdebug
git checkout tags/2.7.2
phpize
Next we need to make a copy phpize so we can edit the include path :
cp /usr/bin/phpize .
nano ./phpize
Find this line :
includedir="`eval echo ${prefix}/include`/php"
...and replace it with this line :
includedir="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php"
Run phpize:
./phpize
You should now see something like this :
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
Configure & build
We can now configure :
./configure --enable-xdebug
...and run make using our custom SDK location defined as compiler flags :
make CPPFLAGS='-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/main -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/TSRM -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/Zend -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/ext -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php/ext/date/lib'
Might see some warning, just ignore it for now. Finally, we'll need to run :
make install
Again, this command will fail because it can't move the extension to the right place. SIP will prevent it. But no worries, we'll take care of that manually at the next step. make install is still required as it will sign the *.so file.
Enabled support in PHP
Next, we move the executable somewhere safe. I use /usr/local/php/extensions.
sudo mkdir -p /usr/local/php/extensions
sudo cp /usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so /usr/local/php/extensions
Then we edit the PHP configuration to enable Xdebug. Simply edit php.ini:
sudo nano /etc/php.ini
And we add the following at the bottom :
[xdebug]
zend_extension=/usr/local/php/extensions/xdebug.so
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
Restart built in server to be sure :
sudo apachectl restart
And finally test everything went fine :
php -i | grep "xdebug support"
If the above command returns nothing, then Xdebug is not available on your install. Go back the steps to find out what's missing.
Note:
A more complete fix would be to edit the result of php-config --include-dir, which returns /usr/include/php. That would make any installation find the necessary header files without having to manually edit files or compiler flags.
If you are using brew, I solve this by reinstalling php and re-linking:
brew reinstall php#7.3
brew link --overwrite php
I got an error when I tried to install xdebug in MacOS Catalina 10.15:
pecl install xdebug-3.0.1
Error:
/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found
This is due to Apple decided to remove headers file in /usr/include, like you can see in other answer.
Then I added config to .bash_profile, executing these lines in console:
echo 'export PATH="/usr/local/opt/php#7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/php#7.3/lib"
export CPPFLAGS="-I/usr/local/opt/php#7.3/include"
source ~/.bash_profile
After that you can try to install xdebug again with pecl:
pecl install xdebug-3.0.1
Notes: Previously I have installed PHP 7.3 with "brew". You should adjust the php and xdebug version, in the above lines, adding the versions that you prefer.
I would recommend you use "brew" to install PHP, and then use the "pecl" tool that comes with the installed version of brew's PHP to install Xdebug.
you can find detailed instructions with ready to use patches on this site: https://profilingviewer.com/installing-xdebug-on-catalina.html

Building XDebug For Use by MAMP?

I'm using MAMP on Mac OSX Mavericks. I'd like to install the latest XDebug, v2.2.4. Per the XDebug Wizard, I downloaded the XDebug 2.2.4 source. I have many versions of phpize installed on my system - one that is in /usr/bin/, and many others that come with MAMP. MAMP supplies the required phpize for each version of PHP it includes.
Seeking to use the correct phpize, per the XDebug Wizard instructions - http://xdebug.org/docs/faq#custom-phpize - I ran the phpize for PHP 5.5.3 via:
/Applications/MAMP/bin/php/php5.5.3/bin/phpize
..and got this output:
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.5.3/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Just in case this was not an error (since it appeared that I was following XDebug Wizard directions), I then ran configure via:
./configure --with-php-config=/Applications/MAMP/bin/php/php5.5.3/bin/php-config
...and I ran:
make
...but got this error:
fatal error: 'php.h' file not found
What is the correct way to build XDebug on OSX for use by MAMP?
Thanks very much in advance to all for any thoughts or info.
I had a similar issue and it was resolved after installing XCode and the Command Line Tools for XCode. I already had XCode installed, but I recently moved over to a new machine so I had to open it back up and it updated some things. Then I opened Terminal and ran the command...
xcode-select --install
That popped up a prompt to install the command line tools which I did and it resolved my issue.
Incase anyone else stumbles across this from Google...
My issue was the wrong phpize binary was found on the path.
I was able to resolve this using the Xdebug FAQ, specifically this section: https://xdebug.org/docs/faq#custom-phpize
When Xdebug wizard asks you to run phpize, instead find and run phpize in your MAMP directory. For me, this was:
/Applications/MAMP/bin/php/php7.1.19/bin/phpize
After this, you should see an output similar to your tailored installation instructions.
Then find and run php-config in your MAMP directory (Note: this command must be run from where you have Xdebug stored on your machine). For me, this was:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.1.19/bin/php-config
You'll see a bunch of output... Followed by a, "Build complete." message.
Now you can return to your tailored installation instructions (be sure to skip the next step, Run: ./configure).
Try installing autoconf using brew : brew install autoconf

Two versions of PHP - Mountain Lion

I have somehow got 2 versions of php installed on my machine (Mac OSx 10.8.3 Mountain Lion). The locations of the 2 versions are -
/opt/local/bin (version 5.3.26)
/usr/bin (version 5.3.14)
Right now, 'php -v' in the terminal returns, 5.3.26 but a simple php test page with the following code
phpinfo();
return 5.3.15.
Because of this mix-up i cant get php to load the mongodb extension. I'd want to work with version 5.3.26.
How do i get Apache to load this version of php ?
Your Apache is including libphp5.so of the wrong/the other installation.
Option 1:
See if you can find a libphp5.so file for your other PHP installation and point the Apache config to it (just put the whole path in the LoadModule line and restart Apache). If you cannot find such a file, the Apache module wasn't compiled for that PHP version. Compiling that may be a bit complicated, so in that case:
Option 2:
Figure out which PHP you're executing on the command line using which php and then just use the other one using the full path, e.g. instead of $ php ... use $ /usr/bin/php .... Note that you may still have different PHP configuration files for Apache and the CLI.

Trouble with PHPUnit on Zend Server CE - MacOSX

I've installed Zend Server CE on my MacOS Lion, and everything is running smooth except from PHPUnit.
My installation of PHPUnit was made from the PERL that comes with Zend Server CE.
Here is the output from when I run phpunit through the console:
Failed loading ”/usr/local/zend/lib/php_extensions/xdebug.so”: dlopen(”/usr/local/zend/lib/php_extensions/xdebug.so”, 9): image not found
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/mcrypt.so' - dlopen(/usr/local/zend/lib/php_extensions/mcrypt.so, 9): Library not loaded: /usr/lib/libltdl.3.dylib
Referenced from: /usr/local/zend/lib/php_extensions/mcrypt.so
Reason: image not found in Unknown on line 0
PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0
PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/local/bin/phpunit on line 39
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpunit:0
Does anybody know what the problem or problems could be?
Thanks and regards!
Ok, this is my first answer. So go easy on me.
Tonight I had the very same issues with Zend Server CE on OSX Lion. In order to solve them, you'll have to install xcode as the unix development tools are required.
Let's get started, you have two issues: xdebug.so and libltdl.3.dylib
First xdebug.so is not found, to install it you should run the following from the command line:
sudo su -
It will ask you for you password (if you don't have one just press the enter key). Then:
export CFLAGS="-arch i386 $CFLAGS"
export CCFLAGS="-arch i386 $CCFLAGS"
export CXXFLAGS="-arch i386 $CXXFLAGS"
export LDFLAGS="-arch i386 $LDFLAGS"
/usr/local/zend/bin/pear config-set php_ini /usr/local/zend/etc/php.ini
/usr/local/zend/bin/pecl install xdebug
The first four lines, force the compiler to generate a 32 bit binary, as Zend Server is a 32 bit binary and OSX Lion is a 64 bit operating system.
Alright, now you should have xdebug.so installed on */usr/local/zend/lib/php_extensions*, just make sure that your /usr/local/zend/etc/php.ini file loads xdebug with the following line after all other extensions and before the [zend] section:
zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
Here's the fragment from my php.ini:
...
;extension=odbc.so
;extension=imagick.so
zend_extension=/usr/local/zend/lib/php_extensions/xdebug.so
[zend]
zend_extension=/usr/local/zend/lib/ZendExtensionManager.so
...
If it doesn't please add it manually, then check if your php.ini file contains the following line and delete it as xdebug must me loaded as a Zend extension.
extension=xdebug.so
Second, as soon as you install xcode, libltdl.dylib will be available in /usr/lib, so you can create a symbolic link to it with the following command:
sudo ln -s /usr/lib/libltdl.dylib /usr/lib/libltdl.3.dylib
Next time you run phpunit everything should go smoothly (haven't tested any mcrypt functions though).
I just ran into the problem with the mcrypt, when I tried to start the phpunit.
The warning does not appear, if you run phpunit with sudo :)
sudo ./phpunit --version
PHPUnit 3.6.6 by Sebastian Bergmann.

Resources