ActiveState Community

Calltips for PHP

Posted by Isaak on 2008-03-11 15:03

I've never been able to use the PHP calltips and interpreter in Komodo.
Whenever I write a PHP function an error of this kind will be displayed:

ERROR: codeintel: error evaluating 'filemtime' at core.php#463
Traceback (most recent call last):
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\manager.py", line 400, in run
    self._handle_eval_sess(eval_sess)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\manager.py", line 417, in _handle_eval_sess
    eval_sess.eval(self)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\tree.py", line 318, in eval
    calltips = self.eval_calltips()
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\tree_php.py", line 212, in eval_calltips
    hit = self._hit_from_citdl(expr, start_scope)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\tree_php.py", line 522, in _hit_from_citdl
    hit, nconsumed = self._hit_from_first_part(tokens, scoperef)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\tree_php.py", line 636, in _hit_from_first_part
    hit, nconsumed = self._hit_from_elem_imports(tokens, elem)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\tree_php.py", line 654, in _hit_from_elem_imports
    libs = self.buf.libs
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\lang_php.py", line 1267, in libs
    return self.langintel.libs_from_buf(self)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\lang_php.py", line 1053, in libs_from_buf
    libs += self._buf_indep_libs_from_env(env)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\lang_php.py", line 1170, in _buf_indep_libs_from_env
    = self._php_info_from_php(php, env)
  File "C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\lang_php.py", line 1105, in _php_info_from_php
    stdout_lines = stdout_lines[stdout_lines.index(marker)+1:]
ValueError: list.index(x): x not in list
ERROR: koCodeIntel: error evaluating calltip:
  trigger: 
  log:
    info: eval 'filemtime' at core.php#463  
    info: _hit_from_citdl:: expr: 'filemtime', scoperef: (, ['core', 'loadCSS'])
    info: _hit_from_citdl:: expr tokens: ['filemtime']
    info: _hit_from_first_part:: find 'filemtime ...' starting at (, ['core', 'loadCSS']):
    info: _hit_from_first_part:: scoperef now (, ['core', 'loadCSS']):
    info: _hit_from_first_part:: is 'filemtime' accessible on (, ['core', 'loadCSS'])? no
    info: _hit_from_first_part:: scoperef now (, []):
    info: _hit_from_first_part:: is 'filemtime' accessible on (, [])? no
    debug: _hit_from_elem_imports:: Checking imports, tokens[0]: 'filemtime' ... imp_elem: 
    error: error evaluating 'filemtime' at core.php#463: ValueError: list.index(x): x not in list (C:\Program Files\ActiveState Komodo Edit 4\lib\mozilla\python\komodo\codeintel2\lang_php.py#1105 in _php_info_from_php)

And when trying to set the path to the installed PHP interpreter, an error will always be displayed saying that this is not a supported PHP version. My PHP version is 5.2.5.

Does anyone have more information on this?

Thank you

jeffg | Wed, 2008-03-12 09:46

What version of Komodo Edit are you using? The current version is 4.3:

http://www.activestate.com/Products/komodo_ide/komodo_edit.mhtml

As well, it seems like there may be an issue with your PHP interpreter. can you please try the following:

1. in Komodo, hit Ctrl+R to bring up the Run Command dialog
2. in the 'Run' field paste in this:

echo "%(php)" && "%(php) -m"

3. hit the 'Run' button.

What is the output of this command?

--
JeffG

Isaak | Wed, 2008-03-12 15:34

I'm not sure whether you had a reason for it but the command had a mistake, the output was:

"C:\e-Server\php\php.exe" 
'"C:\e-Server\php\php.exe -m"' is not recognized as an internal or external command,
operable program or batch file.

So I "fixed" it which displayed the PHP extensions installed using this command:
echo "%(php)" && "%(php)" -m

I have the latest version of Komodo: 4.3

--
Isaak Malik
Web Developer

jeffg | Wed, 2008-03-12 15:44

Sorry about that. The purpose of the command was to see if running PHP produced some sort of error due to an extension.

Was Xdebug in the list of extensions loaded?

--
JeffG

Isaak | Thu, 2008-03-13 05:01

No Xdebug isn't in the list, should this be enabled in my php.ini?

--
Isaak Malik
Web Developer

jeffg | Thu, 2008-03-13 07:04

The php.ini your PHP uses by default doesn't need to load Xdebug, Komodo keeps a separate php.ini file in your Prefs directory for local debugging that does this. It was just a question directed to try and diagnose why this is failing so badly for you. I am going to run your error messages by the rest of the team and see if we can try to deduce what is going wrong there.

--
JeffG

Isaak | Thu, 2008-03-13 09:31

Ok, in the meanwhile I'll also try several things and hope to find more information about this issue.

--
Isaak Malik
Web Developer

Isaak | Tue, 2008-03-18 08:04

Is there any update on this yet?

Thanks
--
Isaak Malik
Web Developer

jeffg | Tue, 2008-03-18 08:29

Sorry I was at a conference last week and am still digging myself out. We did look into this a bit. The error is coming in some code we use to determine the PHP version. That traceback indicates that running this PHP code:

<?php
echo("--- Start of Good Stuff ---\n");
echo(phpversion()."\n");
echo(ini_get("include_path")."\n");
?>

(a) exited with a successful return value
(b) did NOT output "--- Start of Good Stuff ---"

So something seems to be wrong either with your PHP or how we are running it. We can't reproduce the issue locally with the same version of PHP so our tendency is to blame your PHP.

--
JeffG

Isaak | Tue, 2008-03-18 12:51

Well, that would be the most logical assumption. Could you tell me what PHP properties on Windows Komodo depends on? Does it depend on registry keys, extensions or a certain library?

I'd like to look into this myself since the issue seems to be on my side.
--
Isaak Malik
Web Developer

jeffg | Tue, 2008-03-18 13:51

All we do is run the configured PHP executable and pass in that code, then scan the output for version information. The usual point of failure is that we get back unexpected output from PHP ( for example a linking issue with an extension ).

Komodo itself does not access the registry or anything like that, but PHP builds on Windows can somtimes pick up registry values pointing to a different php.ini. I think Zend Studio uses registry entries for this. So I would try ( as a long shot ) searching for 'php.ini' in your registry, particularly if you have had Zend Studio installed previously.

--
JeffG

ToddW | Tue, 2008-03-18 14:55

Isaak, can you provide the resulting output when running this script on your php interpreter. You can use the Komodo Run command system, something like this: "C:\e-Server\php\php.exe %F", where the %F will be translated into the current script path, with the script contents containing:

<?php
echo("--- Start of Good Stuff ---\n");
echo(phpversion()."\n");
echo(ini_get("include_path")."\n");
?>
<?php
echo("--- Start of Good Stuff ---\n");
echo(phpversion()."\n");
echo(ini_get("include_path")."\n");
?>

Thanks,
Todd

Isaak | Tue, 2008-03-18 16:12

Hey Jeff, I indeed have installed Zend Studio before, do you think this affects Komodo and PHP in any way? I also always install PHP manually and don't use the Windows binary installations, that's why I asked if Komodo used registry keys.

Hey Todd,
PHP runs this command via Komodo perfectly, the output was:

--- Start of Good Stuff ---
5.2.5
.;C:\e-Server\php\PEAR

I have no clue what could be wrong so I doubt that I will find the solution anytime soon, but hey this is a very useful feature so I keep trying.

Edit: I found that this issue is caused by my php.ini, I replaced my current one with the PHP recommended one and the calltips started to work. Now I'm going to find out which part is causing it.

Another edit: I've made a few changes and it still worked so since it's working for me now I'm going to continue working on my projects, I hope no one else was interested in knowing the cause ;).

--
Isaak Malik
Web Developer

Isaak | Thu, 2008-03-20 13:39

It seems that using the default php.ini only worked temporary, the calltips stopped functioning again after a computer reboot, I had made a few changes to the php.ini but it kept working until the reboot.

Here are the contents of the error log: http://www.paste2.org/p/16735
--
Isaak Malik
Web Developer

jeffg | Thu, 2008-03-20 16:51

So, what you have now is the same problem, where Komodo is not getting the correct output from PHP. We can't reproduce this locally using the following methodology:

- install PHP 5.2.5 and configure it with Komodo
- use the default php.ini-dist file provided

Just as a test, if you install the zip package of PHP 5.2.5 from php.net, re-name php.ini-dist to php.ini, then configure that with Komodo, does it work?

As well, if you search your Windows registry with regedit for 'php', what keys are found? The key should be this one:

HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath

--
JeffG

Isaak | Fri, 2008-03-21 06:10

Hey,

I have tried several things in order to get this feature working, even though you can manually set the php.ini location in Komodo it will not work if the file name is not php.ini, I renamed the default PHP configuration file to php-komodo.ini in order to be able to use the PHP calltips feature but Komodo was still loading the php.ini in the same directory.

In a mysterious way the calltips started working again when I removed the Zend Optimizer details from my php.ini, even though I also did this before with no result.

I hope that it will keep functioning from now on, and I'd like to thank you for your assistance up 'till now. But there is one more thing I'd like to know:
Is it possible to disable calltips for custom made functions and variables or prevent Komodo from scanning files in the whole directory? This feature kept on scanning the complete PEAR directory and memory usage increased very fast, I removed the PEAR directory from the include_path in my php.ini but I'd like Komodo to stop scanning directories for PHP files or disable the custom variable and function calltips completely.

Thank you in advance.

--
Isaak Malik
Web Developer

jeffg | Sun, 2008-03-23 20:31

The best approach is to remove the path toe PEAR from your php.ini; Komodo scans and includes all PHP files on the current include_path.

--
JeffG

camilo_u | Wed, 2008-05-07 13:30

I was having exactly the same issue, i had the same version of PHP, but i was using Vertrigo (an application that has PHP, Apache, Mysql and some other stuff)

I just downloaded the latest version of php (5.2.6, the 9,5 mb one) uncompressed the file on c:\php added the folder to the windows path, added the folder to komodo (4.3.2) and bingo!

Please give it a try and let me know if works!

Camilo