relative require directory
Moderator: kfury77
Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
Please try to follow these guidelines. This will help to receive faster and more accurate response.
- Check the Support section of the corresponding product first. Chances are you will find your answer there;
- Do not create new topics for already reported problems. Add your comments to the existing topics instead;
- Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
- Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
- Include the version number of the software you are using;
- This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
relative require directory
Hi,
I have a problem with my PHP classes to do with the directory support in WeBuilder 2008.
In a project, I have the following directory structure.
classes/base
Registry.php
classes/controller
ApplicationHelper.php
Request.php
Controller.php
My class Controller.php begins ...
<?php
require_once( "classes/base/Registry.php"); // using the real one now
require_once( "classes/controller/ApplicationHelper.php"); // using the real one now
require_once( "classes/controller/Request.php"); // using the real one now
class Controller {
private $applicationHelper;
private function __construct() {}
static function run() {
$instance = new Controller();
$instance->init();
$instance->handleRequest();
}
function init() {
$applicationHelper = ApplicationHelper::instance();
$applicationHelper->init();
}
...
}
?>
This runs fine since all required files are relative to the application directory and all the required files are found and loaded.
In the WeBuilder 2008 editor however, the file cannot be opened since it appears to change directory to the directory containing the file it has just loaded.
If I load Controller.php, select the require for 'classes/controller/ApplicationHelper.php' in the code explorer and try to open it... I get...
File C:\..........\cyber\classes\controller\classes\controller\ApplicationHelper.php not found. So the file it is trying to open appears to be relative to the file being edited rather than relative to the root of the project.
Is there a setting somewhere that I can set to correct this ?
Regards,
Steve
I have a problem with my PHP classes to do with the directory support in WeBuilder 2008.
In a project, I have the following directory structure.
classes/base
Registry.php
classes/controller
ApplicationHelper.php
Request.php
Controller.php
My class Controller.php begins ...
<?php
require_once( "classes/base/Registry.php"); // using the real one now
require_once( "classes/controller/ApplicationHelper.php"); // using the real one now
require_once( "classes/controller/Request.php"); // using the real one now
class Controller {
private $applicationHelper;
private function __construct() {}
static function run() {
$instance = new Controller();
$instance->init();
$instance->handleRequest();
}
function init() {
$applicationHelper = ApplicationHelper::instance();
$applicationHelper->init();
}
...
}
?>
This runs fine since all required files are relative to the application directory and all the required files are found and loaded.
In the WeBuilder 2008 editor however, the file cannot be opened since it appears to change directory to the directory containing the file it has just loaded.
If I load Controller.php, select the require for 'classes/controller/ApplicationHelper.php' in the code explorer and try to open it... I get...
File C:\..........\cyber\classes\controller\classes\controller\ApplicationHelper.php not found. So the file it is trying to open appears to be relative to the file being edited rather than relative to the root of the project.
Is there a setting somewhere that I can set to correct this ?
Regards,
Steve
Re: relative require directory
I tacked the following onto the end of an old thread a few weeks ago. Much the same issue, so I'll repost here:
Add me to the 'would like this feature' list please. I use root (as opposed to document) - relative links on all projects, for all sorts of reasons.
Am a recent convert to WeBuilder, having used Dreamweaver for years, but one good thing about DW was that on the 'insert image' or 'add link' browse dialogue, you had the option to select either 'root relative' or 'document relative' when the path was written. This was a sticky setting, so it stayed at whatever was last used.
Have always preferred the convenience of /root/relative/links and would like to not continuously have to manually remove the likes of /./.../. after links are coded.
Thanks
Re: relative require directory
bump....
Is there any information on this issue ?
Is there any information on this issue ?
- Karlis
- Site Admin
- Posts: 3605
- Joined: Mon Jul 15, 2002 5:24 pm
- Location: Riga, Latvia, Europe
- Contact:
Re: relative require directory
This is not a question of weeks, more like months or half a year, because path procesisng is an internal thing that goes deep in the algorithms and it is not an easy-to-add feature, but it is in sight. I can and will not promise anything at this point yet.
Re: relative require directory
Ah well, something to look forward to, then. Thanks for replying.
- Karlis
- Site Admin
- Posts: 3605
- Joined: Mon Jul 15, 2002 5:24 pm
- Location: Riga, Latvia, Europe
- Contact:
Re: relative require directory
A question. Doesn't you have to use require_once( "/classes/base/Registry.php"); instead of require_once( "classes/base/Registry.php"); to make it relative to root?
The "classes/base/Registry.php" will work only if Controller.php is included in some index.php file run from the root or if the Controller.php sits under the root.
So the question, how one can tell that controllar.php which itself does not sit under the /Controller.php will be actually run from the root?
The "classes/base/Registry.php" will work only if Controller.php is included in some index.php file run from the root or if the Controller.php sits under the root.
So the question, how one can tell that controllar.php which itself does not sit under the /Controller.php will be actually run from the root?
Re: relative require directory
The specific example above isn't mine, so I can't answer with 100% certainty, but I'd say yes, you are right to say that the path should start with a / to indicate 'starting at root'.
Using /root/relative/links makes a lot of things easier in terms of snippets/libraries/code portability.
Using /root/relative/links makes a lot of things easier in terms of snippets/libraries/code portability.
- Karlis
- Site Admin
- Posts: 3605
- Joined: Mon Jul 15, 2002 5:24 pm
- Location: Riga, Latvia, Europe
- Contact:
Re: relative require directory
We will be exploring the possible ways of introducing support for absolute paths (that use project root as the root).
Re: relative require directory
Again, good to know. But, just to be really pedantic, my understanding of what is meant by 'absolute' is the full and complete version of a URL. I'm only stressing this to try and avoid potential communication problems.
Absolute: http://www.blumentals.net/file.php
Root relative: /file.php
Document relative: ./../file.php
The first two NEVER change, does not matter where you are referencing them, they will be identical regardless of which directory you call them from. The third will change every time, will be different according to which directory you call it from.
Absolute: http://www.blumentals.net/file.php
Root relative: /file.php
Document relative: ./../file.php
The first two NEVER change, does not matter where you are referencing them, they will be identical regardless of which directory you call them from. The third will change every time, will be different according to which directory you call it from.
- Karlis
- Site Admin
- Posts: 3605
- Joined: Mon Jul 15, 2002 5:24 pm
- Location: Riga, Latvia, Europe
- Contact:
Re: relative require directory
By absolute I mean root relative in my language.