NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to set up PEAR so code completion works...


Joined: 29 Nov 2004
Posts: 5
Reply with quote
I've been evaluating PhpED v3.3.3 (Build 3395eval) on Windows 2000 with DBG 2.16.14 and I can't get the code completion to work when using PEAR DB. I've tried several different ways: including the PEAR directory in the same project, as a separate project within my workspace and even having DB.php file open, but the code completion does not work. The code explorer does work, though and running/debugging works properly.

Am I missing something to get this working?
View user's profileFind all posts by kdl69Send private message


Joined: 09 Dec 2003
Posts: 92
Reply with quote
I'm not absolutely sure (I do not work for nusphere Wink), but the code completion feature depens - or say respects Rolling Eyes - the files require()d or include()d by your script.

Please try both of the following:

1. Include the file (DB.php?) with a full relative path from your script and see if it works.

2. Point the "include path" setting in your project's properties to the PEAR folder containing the DB.php file and require 'DB.php'.

Maybe this thread might also be helpful: code-completion-for-project-code-snippet-search-t1096.html
View user's profileFind all posts by mpSend private message


Joined: 29 Nov 2004
Posts: 5
Reply with quote
No luck. I tried it both ways.

I also went through all of the topics, FAQs and documentation I could find. It seems like it will only work with classes if the files exist under the project root directly.

Any other ideas?

Thanks
View user's profileFind all posts by kdl69Send private message


Joined: 09 Dec 2003
Posts: 92
Reply with quote
From the "project settings" help:

Quote:
Include path. If you have any files, e.g. 3rd party libraries (like Smarty, etc.), located in the directories out of the project tree and these files are referenced from the project files, you can specify the out of project directories where the Code Insight will search these files in. The button to the right side of the Include path field brings up a dialog box to edit the list of these directories.


I'm almost sure that should be what you are looking for?
View user's profileFind all posts by mpSend private message


Joined: 29 Nov 2004
Posts: 5
Reply with quote
Nope. I have the path to PEAR in the "Include Path" of the project settings. If I don't have it there, then the page(s) can't be previewed or debugged.

That is why I'm stumped...
View user's profileFind all posts by kdl69Send private message


Joined: 09 Dec 2003
Posts: 92
Reply with quote
Strange. A while ago, I had a similar problem and wanted to require some files located out of the project root with a file require"file.php" (without a path).

I had to modify the php.ini include_path for that, setting the project properties include path did not help. As I understood it that time, this setting only affects code completion, but does not affect php.

(Without having tested that, that setting from the project properties probably won't show up in the output of a phpinfo() call?)
View user's profileFind all posts by mpSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
Please make sure you understand that the Include Path mentioned is in the PROJECT SETTINGS, not the one in php.ini.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 29 Nov 2004
Posts: 5
Reply with quote
Yes, the include path is set in the PROJECT SETTINGS...

Here is a sample of the code I'm working with, if it helps:

Code:
<html>
<head>
<title>Test</title>
</head>
<body>
<ul>
<?php
include("DB.php");

$dbUser = 'mydb';
$dbPass = 'mydb';
$dbHost = 'localhost';
$dbDatabase = 'mydb';

$dsn = "mysql://$dbUser:$dbPass@$dbHost/$dbDatabase";

$db =& DB::connect($dsn);

if (DB::isError($db)) {
    die($db->getMessage());
}

$db->setFetchMode(DB_FETCHMODE_OBJECT);

$sql = "SELECT id,name FROM product ORDER BY name";

$res =& $db->query($sql);

if (DB::isError($res)) {
    die($res->getMessage());
}

while ($rs =& $res->fetchRow()) {
    echo '<li>' . $rs->name . "\n";
}
$db->disconnect();
?>
</ul>
</body>
</html>


Thanks.
View user's profileFind all posts by kdl69Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
From the code you shown it's impossible to guess what class type (if even class at all) ::connect() method returns. Therefore type of $db variable is unknown and Code Completion can not show you any methods for it.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 29 Nov 2004
Posts: 5
Reply with quote
Is there a way around this? The syntax used is right out of the PEAR docs...

Thanks.
View user's profileFind all posts by kdl69Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8335
Reply with quote
Yes the syntax is correct. But it's the php typeless nature... From the source text it's not known what type of the value is returned by a function, except plain and strightforward situations.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 09 Dec 2003
Posts: 92
Reply with quote
Maybe one could think of a way to work around this by interpreting PHPDoc inline documentation or at least considering them as a hint?

The problem is that most PEAR classes "exploit" PHPs typeless nature by either returning "business" objects or error objects - it's up to you to check what the returned object.

Btw, does PHP5 type hinting only work for the method parameters - that is, you cannot hint to the type being returned? So type hinting would not help here...
View user's profileFind all posts by mpSend private message
How to set up PEAR so code completion works...
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic