 |
 | Code Completion for Included Class Files |  |
Joined: 04 Jun 2004 |
Posts: 9 |
|
|
 |
Posted: Thu Jun 03, 2004 3:28 pm |
|
 |
 |
 |
 |
I don't know if I changed a setting accidently, or if it was never working this way to begin with and I'm smoking crack.
My project is laid out like this.
Project Root\
index.php
class\
class.php
class2.php
modules\
module1\
module1.php
module1-2.php
module2\
module2.php
|
Index.php includes files based on various options from the modules directory. So if index.php includes module1.php, in module.php I would include any needed classes relative to index.php's position in the project, and not it's self.
So in essence I would have something like this...
<?PHP
// index.php
include('modules/module1/module1.php');
?>
|
In module1.php, any classes needed would be included as such.
<?PHP
// module1.php
include('class/class.php');
include('class/class2.php');
$obj = new MyClass;
?>
|
I've only been using PHPEd for about a week now, but it seems to me that if I was working in module1.php, code insite would work correctly on an object invoked from a class, even if the included class definition directory was not relative the its position in the file, because it was included in the project.
However this seems to have quit working, or like I said, maybe I was just smoking crack. Does any body know if I messed up a setting some where or if this is working as intended?
|
|
 |
 | |  |
 |
 | |  |
 |
 | |  |
Joined: 04 Aug 2004 |
Posts: 13 |
|
|
 |
Posted: Sat Jun 18, 2005 4:31 pm |
|
 |
 |
 |
 |
Is there any chance this is going to be fixed anytime soon though? I have the same issues, and it's making me go mad...
1. the auto-code completion thing is a real showstopper if it doesn't work like lagsalot described it (I acually have the exact same structure, which is I believe a very common one  )
2. Also when debugging, the include is always working from the current position..
For instance, take the following example:
index.php
/includes/genericfunctions.inc.php
/includes/securityfunctions.inc.php
What i do in index.php is include /includes/genericfunctions.inc.php and then call the initialising function that should do the rest.
In that initialiser, I want to include the securityfunctions.inc.php, so I do include_once('includes/securityfunctions.inc.php') which is correct, as the script is being executed as index.php - yet, phpED seems to be searching for /includes/includes/securityfunctions.inc.php in stead...
I hope this can be helped soon though  This may get me to renew my licenses 
|
|
 |
 | |  |
Joined: 04 Aug 2004 |
Posts: 13 |
|
|
 |
Posted: Wed Jun 22, 2005 5:00 pm |
|
 |
 |
 |
 |
ddmitrie wrote: | Code completion is supposed to work even if nothing is really executed. How would PhpED know what is the so called "current position"  |
AS far as I can tell, code completion is only there for functions within the file you are editing, or files that you actually included using include() or include_once()...
Regarding your feedback - I'm executing index.php in the root, so it's obvious that all includes should be starting from that location, as this is what PHP does...
I'm not sure you're following what I'm trying to say, but then again it might be my English  Please let me know if you don't really understand what I'm referring to, and I'll try and explain better...
|
|
 |
 | |  |
Site Admin
Joined: 13 Jul 2003 |
Posts: 8355 |
|
|
 |
Posted: Thu Jun 23, 2005 10:49 am |
|
 |
 |
 |
 |
Quote: | AS far as I can tell, code completion is only there for functions within the file you are editing, or files that you actually included using include() or include_once()... |
Not exactly  Let me demonstrate it.
what's about the following?
file a.php:
<?php
function fun_a() {
}
include "b.php";
?> |
file b.php:
<?php
// you're typing here below:
?> |
should function fun_a() be shown in code completion if you're in b.php ?
From the php's perspectives it should.
|
|
 |
 | |  |
Joined: 04 Aug 2004 |
Posts: 13 |
|
|
 |
Posted: Fri Jun 24, 2005 5:35 am |
|
 |
 |
 |
 |
No, but this is not what I'm referring to...
file a.php:
<?php
include_once("b.php");
fun_c();
?> |
file b.php:
<?php
include_once("c.php");
?> |
file c.php:
<?php
function fun_c() {
}
?> |
in the above, code completion will not work when trying to caal fun_c() from within file a.php because it is third level inclusion... if I had a function in file b.php, it does it perfectly well...
The second issue I'm talking about:
file index.php:
<?php
include_once("includes/genericFunctions.inc.php");
?> |
file includes/genericFunctions.inc.php:
<?php
include_once("includes/securityFunctions.inc.php");
?> |
-> this will crash in debug, as it is searching for includes/securityFunctions.inc.php based on the location of the includes/genericFunctions.inc.php file; meaning it will go look for includes/includes/securityFunctions.inc.php, where it should actually, from a php perspective, search based on the location of the file that is actually being executed, in this example being index.php, and should include the file starting from that location in the directory tree...
I hope this all makes sense now...
|
|
 |
 | |  |
Site Admin
Joined: 13 Jul 2003 |
Posts: 8355 |
|
|
 |
Posted: Sat Jun 25, 2005 12:34 pm |
|
 |
 |
 |
 |
Quote: | -> this will crash in debug |
What do you mean
Quote: | as it is searching for includes/securityFunctions.inc.php based on the location of the includes/genericFunctions.inc.php file |
Who? Debugger? Code Insight Engine?
Quote: | meaning it will go look for includes/includes/securityFunctions.inc.php, where it should actually, from a php perspective, search based on the location of the file that is actually being executed, in this example being index.php, and should include the file starting from that location in the directory tree... |
If you mean Code Insight, please tell me how would it guess what file is being executed when you're just typing your code?
If you mean Debugger, it does never seach for anything. Php engine does and always follows its rules.
|
|
 |
 | |  |
 |
 | |  |
Site Admin
Joined: 13 Jul 2003 |
Posts: 8355 |
|
|
 |
Posted: Mon Aug 15, 2005 5:21 am |
|
 |
 |
 |
 |
Quote: | I believe our setup is very common where we have ONE index.php that is ALWAYS being called |
Personally, I'm not sure why index.php would be considered as a root file to call for all the other project files. For example, in PHPBB you're reading right now there are many such "root" files, namely posting.php, index.php, viewforum.php, search.php, memberlist.php, faq.php, profile.php and many many other files.
Quote: | I really don't know what is so incomprehensible about my explanation |
Actually, I didn't mean that. You explained what you want and I tried to explain why it's not so easy in Phped 3.3.
On the other hand, PHPED 4.0 will come with different approach. It captures all the project files, classes, functions, methods etc etc etc and show you codecompletion without much problems with settings and directories the files are located in.
|
|
 |
 | |  |
Joined: 12 Feb 2005 |
Posts: 48 |
|
|
 |
Posted: Mon Aug 15, 2005 9:46 am |
|
 |
 |
 |
 |
Dmitrie
Speedpacket is using a development method (aka Design Pattern) known as the MVC - Its been used for years in the Java market and has become the defacto standard for designing J2EE powered sites, and now its become increasingly more popular with PHP.
http://www.phppatterns.com/docs/design/archive/model_view_controller_pattern
Cheers
|
|
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 2
|
|
|
|  |