xdebug configuring error: Function registration failed - duplicate name - php

I am trying to use xdebug to debug a really large php system. I have added the following lines to the php.ini on a Linux system:
[XDebug]
zend_extension = "/usr/lib/php4/lib/php/extensions/no-debug-non-zts-20020429/xdebug.so"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1 ;
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "/tmp"
However, after restarting apache I am unable to reload a php-generated page in the web-browser. The apache error-log contains the following output:
PHP Warning: Function registration failed - duplicate name - xdebug_get_stack_depth in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_function_stack in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_print_function_stack in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_declared_vars in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_class in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_function in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_file in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_call_line in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_var_dump in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_debug_zval in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_debug_zval_stdout in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_enable in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_disable in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_is_enabled in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_break in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_start_trace in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_stop_trace in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_tracefile_name in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_profiler_filename in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_dump_aggr_profiling_data in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_clear_aggr_profiling_data in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_time_index in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_start_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_stop_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_code_coverage in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_get_function_count in Unknown on line 0
PHP Warning: Function registration failed - duplicate name - xdebug_dump_superglobals in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
[Wed Jun 11 17:26:56 2014] [notice] Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/4.4.9-pl0-gentoo configured -- resuming normal operations
[Wed Jun 11 17:27:01 2014] [notice] child pid 21745 exit signal Segmentation fault (11)
[Wed Jun 11 17:27:02 2014] [notice] child pid 21752 exit signal Segmentation fault (11)
How to fix this problem so I can use xdebug to debug the php system?
Additional information:
There is also a xdebug.ini file - so I removed all xdebug related text from php.ini.
I have added the following two lines to the php code I want to debug:
xdebug_enable();
xdebug_start_trace();

Configuring Xdebug for PHP development/Linux
XDEBUG EXTENSION FOR PHP | DOCUMENTATION
Installation
There are several ways to download and install Xdebug to your Linux box, you can do it from your software center, terminal or manual download.
Method 1: From a Linux repository
A Tip!
This is the recommended method because you will get updates and
security patches automatically.
Option 1: Terminal
Open your terminal and type
sudo apt-get install php5-xdebug
Wait until the installation process finish
Option 2: Software center
Open the software center that comes with your distribution
Type in the search box "Eclipse IDE"
Select "Eclipse IDE" in the search result list
Click on the "install" button
Wait until installation processes finish
Method 2: From a downloaded copy
Visit this page here and download the most recent version available
Do a double click on the downloaded file, your package manager should do the rest of the work automatically http://packages.debian.org/sid/php5-xdebug
Configuring Xdebug
Open your terminal and type
sudo gedit /etc/php5/mods-available/xdebug.ini
if the file is empty try this location
sudo gedit /etc/php5/conf.d/xdebug.ini
hat command should open the text editor with the Xdebug configuration file
At the end of the file content append the following text
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
Save changes and close the editor
In you terminal type
sudo service apache2 restart
Note: You can set a different port number if you need to.
Configuring Eclipse IDE
Open Eclipse IDE
On Eclipse go to: "Toolbar → Window → Preferences → PHP → Debug"
Find the option: "PHP Debugger" and set it to "Xdebug"
On Eclipse go to: "Toolbar → Window → Preferences → PHP → Debug → Installed Debugger"
In the list make sure the port the "Xdebug" option is set to the value "9000"
Save changes
Note: You can set a different port number if you need to.
When you debug a PHP project Xdebug stops the code execution of the current page and Eclipse IDE by default pops out a perspective with 2 views containing the internal Eclipse IDE web browser and the a view with the current HTML output, if you don't like the internal web browser you can use any other external web browser you got installed in your computer, such as gogle chrome, chromium, firefox, etc... don't even try IE, just kidding :p .
To set up a different web browser follow these steps if you are OK with the Eclipse internal browser skip this part:
On Eclipse go to: "Toolbar,Window,Preferences,General,Web Browser"
Make sure the option "Use external browser" is selected
If your preferred browser is on the list, select it and save changes and skip the rest of this part
If your preferred browser is not on the list press the button "New"
Set a name for your new browser i.e. "chrome"
Set the location of your new browser i.e. "/usr/bin/google-chrome"
If you don't know the location of the browser open a terminal and use the command "whereis browsername" to display the browser location. Note: Replace browsername with the name of your preferred browser i.e. "whereis google-chrome" copy one of the locations if there is more than one
Save all changes
Testing Xdebug and Eclipse IDE
To test our brand new debugging tool we need to create an Eclipse PHP project, set the debug configuration for our project and write some few lines of PHP code. This example assumes 3 things:
You understand the Eclipse IDE concepts of "workspace" and "projects", if not, pleas read this article Configuring Eclipse IDE for PHP development/Linux#Understanding the folder structure
You already have a working web server if not, pleas read this article. Configuring a LAMPP server for PHP development/Linux desktop
Your Eclipse workspace is located at the server's web root folder.
Configuring the workspace
If your current workspace is located at your server's web root skip this part
Open Eclipse IDE
On Eclipse go to: "Toolbar → File → Switch workspace → Other"
Press the button "browse" and browse the location of your server's web root folder, i.e. "/home/youruser/lamp/public_html/"
Press "OK" and wait until Eclipse IDE restarts and load the new workspace
Configuring the test project
On Eclipse go to: "Toolbar → File → New → Other → PHP → PHP Project"
Set the project name to "xdebug-test" or anything you like
Press "Ok" to continue
After this Eclipse IDE will automatically create a project folder like this "/home/youruser/lamp/public_html/xdebug-test/", also you should be able to visualize the new project at the Eclipse IDE Project Explorer view or Navigation view
On Eclipse go to: "Toolbar → File → New → Other → PHP → PHP File"
Set the file name to "index.php"
Press "Ok" to continue
After this Eclipse IDE will automatically create a PHP file like this "/home/youruser/lamp/public_html/xdebug-test/index.php", also you should be able to visualize the new file at the Eclipse IDE Project Explorer view or Navigation view
Find the new "index.php" file at the Eclipse IDE project explorer and open it doing double click on it
Place the following content to that file:
<?php
$X = 5;
$X = 8;
$Y = 2;
$Z = $X + $Y;
$Z = $Z + 1;
echo "Z value is: " . $Z;
?>
Save changes
open your web browser and navigate to
"http://example.com/xdebug-test/index.php"
It should display a web and output like this
Z value is: 11
Configuring the test project debug information
On Eclipse go to: "Toolbar → Run → Debug configuration..."
On the left list find "PHP Web Application" and do a double click on it to create a new configuration element
Select the new configuration element to display it content
Set the name to "xdebug-test" or anything you like
Make sure the option "Server debugger" is set to "Xdebug"
Make sure the option "Break at first Line" is not checked
In the option "File" press the button "Browse", find your project "xdebug-test" and expand it content, then find and select the file "index.php"
Make sure that option URL looks something like this "http://example.com/xdebug-test/index.php"
Press "Apply" and "Close" to save changes and continue
Debugging the test project
As you can see our "index.php" file have several lines of code, with the debugger we can study how those lines of code that are being executed one by one, but to stop the execution we need to set something called "Breakpoint", a Breakpoint is a "mark" in our lines of code that indicate to the debugger to stop the execution and poll the var values. To set a Breakpoint on our code and test the debugger follow this simple steps.
Open the "index.php" of our test project
Locate the line of code "$X
= 8;" and do a click on it to place the blinking cursor there
On Eclipse go to: "Toolbar → Run → Toggle Breakpoint", you can also used
the hotkey "shift+ctrl+B" or simply do a double click on the line
number of the line of code at the very left side of your editor to
toggle a Breakpoint
When a Breakpoint is set you should see it
represented as a little circle next to the line number at the very
left side of your editor
Now is time to execute our project to see how the debugger help us to debug the code.
On Eclipse go to: "Toolbar → Run → Debug", you can also used the hotkey "F11" or simply do a click in the "little bug icon" located at the second toolbar from the top
Automatically Eclipse will open the configured web browser, and also change to the "Debug perspective", the debug perspective contains a set of pre-configured views useful to do debugging tasks, among them we got:
Debug view: It display buttons to control the current running debug session and also this view contains the current call stack
Breakpoint view: display all the your set breakpoints on any project file
Variables view: Is is basically a "var dump" of all the PHP variables of your actual session, it view let you easily navigate throw any variable and child members of those variables.
Expressions view: there you can set custom expressions i.e. "$X+$Y+$Z" and see the outcome of each expression without changing the code at all.
Internal browser view and output view: optional if you not configured an external browser Eclipse IDE will display this view with the current page and the current page HTML output
At this point our web page should look stopped and most likely the browser will show a blank page "waiting" to load the rest of it
Note that the current breakpoint have a "little arrow" over the circle and the line of code if highlighted, this indicated what is the next line of code to be executed, also know as the "current step"
If you take a look at the "variables view" the current value of "$X" should be "5"
Go to the "Debug view" and press the button "step over" or use the hotkey "F6" to go one step forward in the code execution
Take another look at the "variables view" the current value of "$X" should be now "8"
This way you can neatly study how your code and values changes step by step, you can also hover your mouse pointer over the variables names in the editor Eclipse IDE will pop up the current value of them.
Keep going froward until the end of the lines of code, at that point the web browser should display the final web page output

Related

PhpStorm - Synology - CLI Interpreter - Updates

I want to create a new project in PhpStorm, but I can't figure out why I can't add a PHP Interpreter in PhpStorm 2020.1.1.
First some info:
All is starting from my Synology NAS DS415+ with latest DSM 6.2.3-25426.
Installed on NAS:
Web Station
MariaDB 10
phpMyAdmin
PHP 7.2
PHP 7.3
Apache HTTP Server 2.4
SSH-connection is added successfully in PhpStorm.
Z-driveletter is /web-folder.
So, first things first. I created a /composer folder inside my /web folder. Composer.phar is selected in path as you can see.
Then I would select a PHP Interpreter.
I will add a new interpreter, so I click on +-sign.
Because of all is installed on my NAS, I select "From Docker, Vagrant, VM, WSL,Remote,..."
Then I select SSH because I can access my NAS through SSH.
Within SSH configuration I select mine. Test Connection => Successfully connected!
Now, I needed to enter the PHP interpreter path. I've searched on my NAS and found these paths:
/volume1/#appstore/PHP7.3/usr/local/bin/php73
/volume1/#appstore/PHP7.2/usr/local/bin/php72
However, I can NOT browse to these paths or enter one of these paths in the input-field.
Do or did I something wrong?
Could anyone help to get this works?
Update - 06/23/2020
I've created a phpinfo file.
What I've see is that my PHP.ini file path = C:\Windows.
I think that's not the intention? I need my NAS PHP.ini!
How can I configure this?
Update - 06/27/2020
I've created a log file that you can find over here:
2020-06-27 13:41:49,202 [13856671] DEBUG - sh.config.OpenSSHConfigService - Failed to parse OpenSSH configuration file: C:\Users\User\.ssh\config
java.io.FileNotFoundException: C:\Users\User\.ssh\config (System can't find specified file)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
at java.base/java.io.FileReader.<init>(FileReader.java:60)
at com.intellij.ssh.config.OpenSSHConfig.parseFile(OpenSSHConfig.java:91)
at com.intellij.ssh.config.OpenSSHConfigService.a(OpenSSHConfigService.kt:57)
at com.intellij.ssh.config.OpenSSHConfigService.a(OpenSSHConfigService.kt:52)
at com.intellij.ssh.config.OpenSSHConfigService.getConfig(OpenSSHConfigService.kt:29)
at com.intellij.ssh.RemoteCredentialsUtil.connectionBuilder(remoteCredentialsUtil.kt:33)
at com.intellij.ssh.RemoteCredentialsUtil.connectionBuilder$default(remoteCredentialsUtil.kt:27)
at com.intellij.ssh.RemoteCredentialsUtil.connectionBuilder(remoteCredentialsUtil.kt)
at com.intellij.ssh.ui.unified.SshCredentialsEditorEx$1.a(SshCredentialsEditorEx.java:68)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11)
at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:255)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
2020-06-27 13:41:58,050 [13865519] DEBUG - ellij.ssh.SshConnectionService - Creating sftp channel within SshjSshConnection(<crc32=1xag9ud>#<crc32=hwmx1i>)#54eb5487
2020-06-27 13:41:58,061 [13865530] WARN - net.schmizz.concurrent.Promise - <<chan#16 / open>> woke to: Opening `session` channel failed: open failed
2020-06-27 13:41:58,061 [13865530] DEBUG - ellij.ssh.SshConnectionService - Creating sftp channel within SshjSshConnection(<crc32=1xag9ud>#<crc32=hwmx1i>)#2c5f9c31
2020-06-27 13:41:58,062 [13865531] INFO - .channel.direct.SessionChannel - Will request `sftp` subsystem
2020-06-27 13:41:58,069 [13865538] WARN - net.schmizz.concurrent.Promise - <<chan#6 / chanreq for subsystem>> woke to: net.schmizz.sshj.connection.ConnectionException: Request failed
2020-06-27 13:41:58,069 [13865538] INFO - tesdk.ui.CreateRemoteSdkUIUtil - Request failed
com.jetbrains.plugins.webDeployment.CustomFileSystemException: Request failed
at com.jetbrains.plugins.remotesdk.RemoteSdkUtil.checkInterpreterAndCreateHelpersDir(RemoteSdkUtil.java:360)
at com.jetbrains.plugins.remotesdk.RemoteSdkUtil$1.lambda$run$0(RemoteSdkUtil.java:297)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11)
at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:255)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.intellij.ssh.SshTransportException: Request failed
at com.intellij.ssh.impl.sshj.SshjSshConnection.openChannel(SshjSshConnection.kt:52)
at com.intellij.ssh.impl.SshConnection.openChannel(SshConnection.kt:67)
at com.intellij.ssh.SshConnectionService.sftp(SshConnectionService.kt:171)
at com.intellij.ssh.ConnectionBuilder.openSftpChannel(ssh.kt:141)
at com.jetbrains.plugins.remotesdk.RemoteSdkUtil.checkInterpreterAndCreateHelpersDir(RemoteSdkUtil.java:356)
... 8 more
Caused by: net.schmizz.sshj.connection.ConnectionException: Request failed
at net.schmizz.sshj.connection.channel.AbstractChannel.gotResponse(AbstractChannel.java:405)
at net.schmizz.sshj.connection.channel.AbstractChannel.handle(AbstractChannel.java:192)
at net.schmizz.sshj.connection.ConnectionImpl.handle(ConnectionImpl.java:130)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decodeMte(Decoder.java:159)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:79)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:231)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
Maybe that could be more informative.

Magento patch failing to install

When downloading and running the Magento PHP 5.4 support patch (Magento-CE-v1.7.0.0-1.7.0.2) from http://www.magentocommerce.com/download, running the script using sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh we receive this error:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
: command not found_1.12.0.0_v1.sh: line 7:
'ATCH_SUPEE-2629_EE_1.12.0.0_v1.sh: line 9: syntax error near unexpected token `{
'ATCH_SUPEE-2629_EE_1.12.0.0_v1.sh: line 9: `_check_installed_tools() {
Strangely, line 7 of the script is blank (here's the head of the file):
#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
We tried the download in Windows and Mac, in Firefox and Chrome to rule out any encoding problems caused by the download process. The patch seems to be very new - Added Jan 17, 2014
We're running Magento Community Edition 1.7.0.2
Edit
We've tried running the .sh file with bash as well but receive the same response.
Interestingly when the click "download", Magento shows the .sh source in the browser so we tried various combinations of view-source then save; copying the text from the browser window and saving it to a text file. None of these solved the problem although one changed the error message to:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
Checking if patch can be applied/reverted successfully...
/usr/bin/patch: **** malformed patch at line 238:
ERROR: Patch can't be applied/reverted successfully.
Line 238 is the blank comment line here:
+/**
+ * Abstract helper class for {#link Zend_Pdf_FileParser} that provides the
+ * data source for parsing.
+ *
+ * Concrete subclasses allow for parsing of in-memory, filesystem, and other
+ * sources through a common API. These subclasses also take care of error
+ * handling and other mundane tasks.
We also tried the VI step mentioned here - :set ff unix
http://www.magentocommerce.com/boards/viewthread/864518
The error then changed to:
$ sh PATCH_SUPEE-2629_EE_1.12.0.0_v1.sh
Checking if patch can be applied/reverted successfully...
ERROR: Patch can't be applied/reverted successfully.
patching file app/code/core/Mage/Catalog/Model/Product.php
Hunk #1 FAILED at 1936.
1 out of 1 hunk FAILED -- saving rejects to file app/code/core/Mage/Catalog/Model/Product.php.rej
patching file app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file app/code/core/Mage/Core/Controller/Varien/Router/Standard.php.rej
patching file app/code/core/Mage/Install/etc/config.xml
patching file app/code/core/Zend/Pdf/FileParserDataSource.php
It turns out that this error is given when the patch file (not the file being patched) has line endings which do not match the system on which it is being run.
eg: You will see this error when:
You are running on Linux
Your patch file has Windows line endings
I changed the patch file to have Unix line endings using Sublime:
View > Line Endings > Unix
See also Error patching Magento 1.7.1 Hunk #1 Failed at

no new line in terminal after setting up cakephp

I attempted to set up vi .profile for baking in cakephp but now when I open terminal (mac OSX) I get the following error
PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/php_gd2.dll' - dlopen(/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/php_gd2.dll, 9): image not found in Unknown on line 0
I can't type in any commands into terminal and pressing enter just drops the line down. The "title" of terminal says PHP 5.3.1, so I'm not sure if it somehow left the standard user mode (whatever that's called). I've restarted my computer and terminal opens up with this same message.
Is there some kind of command I can enter in the menus to revert out of this? Can someone please help me get terminal back to "normal."
edit - I went to shell->new command and typed in su root; to log in. This works, however, when I open up a new terminal window I still get the same php error and I can't figure out how to log in normally when terminal opens.
The ~/.profile by defauilt is empty on OSX (at least on my machine). So just commenting everything out or just removing the pieces you added for the cakePHP will clear the parts that are messing up your new shells.

Class 'PharData' not found

I get this error on my production server (CentOS 5.4 and php 5.3.5) :
Warning: include_once(PharData.php): failed to open stream: No such
file or directory in /var/www/ZendFramework/library/Zend/Loader.php on
line 146
Warning: include_once(): Failed opening 'PharData.php' for inclusion
(include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php')
in /var/www/ZendFw/library/Zend/Loader.php on line 146
Fatal error: Class 'PharData' not found in
/var/www/vm/app/Backup.php on line 40
And this is the code which fail :
$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");
This code is working fine on my own computer.
PharData should be included by default in php 5.3+ ...
Thanks for your help!
UPDATE :
I am using the Zend Auto loader feature to load the good php files using this code :
require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
Zend autoloader is doing the include_once(PharData.php).
Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.
To confirm this, run the following script:
<?php
phpinfo();
?>
One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.
If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.

Categories