NuSphere Forums Forum Index
NuSphere Forums
Reply to topic


Joined: 09 Dec 2003
Posts: 92
Reply with quote
Nice to see I'm not alone outta here Cool

I wasn't aware before that code completion depends on the files required() in a script; I thought it would just magically figure out the right one from the whole list that can be seen in code explorer.

We've got a large, modularized app with lots of classes. We chose to write and use a "Classloader" for them. That is, we do not require, include... anything (except PEAR classes out of our hierarchy). Everything is organized in a class tree hierarchy (Java-like); use "Classloader::load('some.package.classname')" to make sure the class is defined.

If the class has not been included yet, the classloader will search in several locations (like the Java CLASSPATH) in a certain (and important) order for "some/package/classname.class.php" and include it. It might also retrieve missing files over the network (kind of installer) or something the like.

I think the "globbing" feature discussed would allow for code completion here, as long as I can point PhpEd to all class directories (maybe recursing subfolders) or already have all classfolders below the project root.

Did that make it on the feature list for 4.0?

Best regards,
mp.
View user's profileFind all posts by mpSend private message


Joined: 15 Dec 2004
Posts: 1
Reply with quote
newyen, lagsalot, Hmmm, mp: I'm there with you, guys! Same situation, equally unhappy.

ddmitrie: great idea with that "globbing" option. I consider this to be the biggest weakness of PhpEd (actually I thought it was a bug). And don't wait for the 4.0, please.
View user's profileFind all posts by PjotrSend private message


Joined: 23 Mar 2005
Posts: 21
Reply with quote
Count me in too!

The way code completion works right now is only smart for small projects, that is to say for projects where you don't need a professional editor like PHPED anyway! Sad

If index.php includes functions.php and later includes content.php, you can't see any of the functions defined in the 1st include while coding the 2nd include. Definitely not smart.

"Globbing" should not only be an option, it should be the default option. This is why we define a project anyway.

Also, our company already uses PhpED and we've gone mad trying to figure out why we couldn't get this thing to work. We are seriously considering moving to Zend now... is that the only solution? Confused


Last edited by fplanque on Fri Mar 25, 2005 12:22 pm; edited 1 time in total

_________________
- François PLANQUE
View user's profileFind all posts by fplanqueSend private messageVisit poster's website


Joined: 03 Apr 2004
Posts: 78
Reply with quote
lagsalot wrote:
ddmitrie wrote:
ahh, surely code completion is smart enough to no waste the space with the full list. If you need a particular function(s) or class(se) to be shown you have to include corresponding file in your source.


Why is this smart? This is the way Zend handles things and it works pretty well.

At anytime, working in any given file the project knows that when I call,

$mail = new Mailer();

$mail->(I get a list of functions and variables)..

Any chance this will be revisted? This is a show killer for me. PHPEd > Debugging than Zend.. But Zend is more user friendly when working with large projects..


Code explorer doesn't due the trick when there is a few hundred classes/functions listed..


I second that. It would be very helpful if 'phped' stopped trying to be so smart, and think more like us humans. There are several situations i've encountered in the program where it is too smart, and thus pisses me off (simple indentation of code for example is one of those).

Anyway, if it were a configurable option to the user I think would be better, because it may be a performance concern why ddmitrie hasn't done it that way. People have complained about huge projects running slowly.. So if he has to go through everything and walk everything all the time polling for updates in a sourcetree with say 5000 php files that could quickly get out of hand. Thinking it through further, he could cull away the unwanted stuff just searching through the includes, which he is doing now, but that is alot of work i'd imagine.

Bottom line is unfortunate though because there are definitely instances when you can call a custom class or function without the file where it is defined being officially included/required (for example a template scenario where only the header.tpl file includes the files, but the nav.tpl and footer.tpl also take advantage of the functions header includes -- and the extension is custom (tpl) so phped has no way to know if it should even look for includes/requires/etc).

Because of those facts, the best solution IMO would be a toggleable option. Something like ([ ] Search entire project tree for codehints) ... Could even be done in a project scope (which may be even more helpful) and set on the project properties page.

Definitely a bummer that zend does something better Smile
View user's profileFind all posts by Rick ChristySend private messageYahoo Messenger
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
If index.php includes functions.php and later includes content.php, you can't see any of the functions defined in the 1st include while coding the 2nd include. Definitely not smart.


Actually this scenario works.
See:

FILE1, named index.php:

Code:
<?
include('connections/localbddconst.php');

$a = new |


FILE2, named localBDDconst.php:

Code:
<?
include('includes/constants.inc.php');


FILE3, named constants.inc.php:
Code:
<?
echo "hello";

class aaa {
    function bbb () {
    }
    function ccc () {
    }
}

/**
* @desc class ddd for testing purposes
 */
class ddd extends aaa {
    function eee() {
    }
    function fff($vv) {
    }
}


Here you are: Smile
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
Bottom line is unfortunate though because there are definitely instances when you can call a custom class or function without the file where it is defined being officially included/required (for example a template scenario where only the header.tpl file includes the files, but the nav.tpl and footer.tpl also take advantage of the functions header includes -- and the extension is custom (tpl) so phped has no way to know if it should even look for includes/requires/etc).

I'm not sure what finally you're talking about. Really, CodeExplorer in PHPED 3.3 update 3 is reimplemented according to this forum thread.
Any further clue noticed? A non-working example would be of more help than a dozen words Smile (Thanks in Advance)
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 03 Apr 2004
Posts: 78
Reply with quote
ddmitrie wrote:
Quote:
Bottom line is unfortunate though because there are definitely instances when you can call a custom class or function without the file where it is defined being officially included/required (for example a template scenario where only the header.tpl file includes the files, but the nav.tpl and footer.tpl also take advantage of the functions header includes -- and the extension is custom (tpl) so phped has no way to know if it should even look for includes/requires/etc).

I'm not sure what finally you're talking about. Really, CodeExplorer in PHPED 3.3 update 3 is reimplemented according to this forum thread.
Any further clue noticed? A non-working example would be of more help than a dozen words Smile (Thanks in Advance)


No not personally, I was just assuming that it was still an issue and trying to figure out how it would be best to politically express agreement with those also desiring the functionality described. Smile
View user's profileFind all posts by Rick ChristySend private messageYahoo Messenger


Joined: 23 Mar 2005
Posts: 21
Reply with quote
ddmitrie wrote:
Quote:
If index.php includes functions.php and later includes content.php, you can't see any of the functions defined in the 1st include while coding the 2nd include. Definitely not smart.


Actually this scenario works.


No it does *NOT*. I think you misunderstood what I'm trying to tell.

You have proven that if file A includes B and B includes C, then A can "insight" the definitions made in C. Yes, I agree recursivity is woking.

What is not working is this:

File A includes B.
File A later includes C.
When you are editing C, you cannot "insight" definitions made in B.


Is this clearer?

In a lot more words:

File a.php:
Code:
<?
   include "b.php";
   $value = 'something';
   include "c.php";
?>

file b.php:
Code:
<?
  class Foo
  {
  }
?>

file c.php
Code:
<?
  $foo = new |
?>
and I don't get code insight for class Foo here although it would be perfectly valid functionning PHP to type this:
Code:
<?
  $bar = new Foo();
?>


Furthermore: If I type
Code:
<?
  $bar = new Foo( $|
?>

I don't get code insight either for my global variable, in order to type this:
Code:
<?
  $bar = new Foo( $value );
?>


(I am using version 3.3.3 buil 3397)

_________________
- François PLANQUE
View user's profileFind all posts by fplanqueSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Hi François,
good example, thanks.

Fortunately, there is a workaround for your case. You can require_once() all the files with classes w/o breaking the functionality...

BTW, as far as I know, in most cases, people use a little different approach when they organize their code. All php files are grouped into two (or more) groups. First one represents a library which contains all classes and functions to be used by other files. And latter do require_once the files from the first group. Moreover, in many cases the library is moved off the web tree as it's often not safe to have them there. I think that's the case for example with PEAR and many other 3rd party libraries.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Mar 2005
Posts: 21
Reply with quote
ddmitrie,

I am glad you got our point here in the end. However I think it's a pity you are understating this issue...

Yes I know how people would include include files and then develop a web page by using what's been included. However, this is only what happens for small projects. Great for demoing PHPEd, but that's not how it works in the real world.

1) In the real world, people do write the include files themselves (vs using prewritten include files) and some of the include files make use of objects defined in another include file! (do I really need to come up with yet another example for this?)

2) In the real world, people use code structures which are a little more complex than a:include+b:code . One of them is the MVC aka Model-View-Controller paradigm. I only use this example because it's a well known concept, not because it's necessarily the best. Anyway in this paradigm it is explicitely stated that the page output should be handled in a separate (INCLUDE) file and not in the "main" file.

I really think you guys are really good at coding PHPED in C++ (or whatever it is) but you might not be practicing large application development in PHP on a regular basis... As a matter of fact, if you carefully re-read this thread you'll see how many developers use code structures far more complex than a:include followed by b:code. Please listen to us!

If we were only including a few prewritten libraries and write some code after that, we would not need something like NuSphere PHPED!


Regarding the workaround, require_once on multiple includes files isn't very efficient, here's what I've been doing so far (if it can help someone else):
(The following would be file c.php in the example above)
Code:
<?
  if( false )
  { /**
     * Include anything you need in code insight here...
     */
    include('a.php');
    include('b.php');
  }
  $bar = new Foo( $value );
?>


Last edited by fplanque on Wed Mar 30, 2005 11:48 am; edited 1 time in total

_________________
- François PLANQUE
View user's profileFind all posts by fplanqueSend private messageVisit poster's website


Joined: 09 Dec 2003
Posts: 92
Reply with quote
Well, before it's getting too hot here... I've seen the "globbing" feature in the 4012 beta, and it seems to work for me, although I cannot judge if the performance hit is critical.

So the problem reduces to "when will the next version be relased" Wink?
View user's profileFind all posts by mpSend private message


Joined: 23 Mar 2005
Posts: 21
Reply with quote
mp wrote:
Well, before it's getting too hot here... I've seen the "globbing" feature in the 4012 beta, and it seems to work for me, although I cannot judge if the performance hit is critical.

So the problem reduces to "when will the next version be relased" Wink?

Yes, the "globbing" feature would definitely take some pain out of the process... however, thinking a little more about it, I think ddmitrie is right when stating it would pollute the insight significantly...

For example, I have a project here where I have included PhpMyAdmin into the project tree. If I turned on the "globbing", I would start to see PhpMyAdmin internals in code insight all over the place.

So, as a matter of fact, selectively specifying which files we need code insight to be aware of isn't that bad... Except doing it with extra includes is ugly, especially when you participate in an open source project. Other devs who are not using PHPED won't understand why the extra includes.

Now it seems to me there's a smart way to handle this by taking advantage of the @uses tag from PHPDocumentor.

The earlier mantioned example would then look like this:
(c.php)
Code:
<?
/**
 * This is the PhpDocumentor DocBlock for c.php
 *
 * @uses a.php
 * @uses b.php
 */
$bar = new Foo( $value );
?>


What do you think? Wouldn't it make sense for code insight to react to thoses @uses ?

This way you don't put any extra include/require/once statements into your code.

phpdoc for @uses: http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags.uses.pkg.html

_________________
- François PLANQUE
View user's profileFind all posts by fplanqueSend private messageVisit poster's website
Code Completion for Project, Code Snippet, Search ...
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 2 of 2  

  
  
 Reply to topic