Need project flexibility

I started evaluating PHPStorm today. I have a project and web server structure such that there are certain files kept outside the document root. The reason is primarily for security. There are sensitive parameters kept in these files, and also certain scripts that can run as cron jobs but also be included in scripts run from the website by administrators. The directory structure thus has a typical document root, but some other directories.

This structure appears not to be accomodated by the PHPStorm concept of a project, which is simply a directory. That is, there seems to be no way to add other directories to the project as in other IDEs. This causes a problem when debugging, because when the critical fiel containing sensitive information is reached, it is not defined in the project. And I cannot seem to set up a mapping for the file either for the same reason - it must be in the project to be mapped.

Is there a solution to this dilemma?

7 comments
Comment actions Permalink

I think I may have found a solution to "project flexibility". Here are the steps:

1. Arrange so that all needed "external" directories are subdirectories of a common parent, including the actual project directory.

2. Create a project with that parent directory.

3. Mark any undesired directories as "excluded" via the context menu in the directory panel. That is, right-click on the directory, then Mark Directory As .. > Excluded.

I will have to use this configuation for a while to see if it works as desired.

0
Comment actions Permalink

Jeff, please try Settings -> Directories -> Add content root.

Kirill

0
Comment actions Permalink

Kirill, thanks for your reply.

I first tried "add content root", but because the "out of docroot" location is the parent directory of the location of the project, it is disallowed because it "dominates" the main content and they are "not allowed to intersect".

But my tentative solution described in a previous post seems to be workable.

0
Comment actions Permalink

Jeff, what about having two content roots: one for document root, other for the directory with secret files?

Kirill

0
Comment actions Permalink
I first tried "add content root", but because the "out of docroot" location is the parent directory of the location of the project, it is disallowed because it "dominates" the main content and they are "not allowed to intersect".

Add Content Root is used when needed folder is located elsewhere (e.g. completely different path) or when you want to add only one of the folders located above/next to project-one (e.g. PROJECT=C:\Projects\MySuperSite and NewContentRoot=C:\Projects\MySharedLibraries)

But my tentative solution described in a previous post seems to be workable.

Yes, it works -- lots of projects/frameworks support this folder scheme (where website root is just subfolder of the project itself -- such folder then would probably be called "public", "httpdocs", "web" or something like that). I'm using this myself all the time.

Some small features may not work properly though (e.g. open file in browser with proper URL as project root not equal to website root).

You may want to mark such website root folder as Resource Root so that some CSS/HTML inspections would not complain about referencing unknown image/resource (as project root not equal to website root and PhpStorm currently has no ability to specify that this particular folder is website root -- for PhpStorm project root = website root).

0
Comment actions Permalink

Having two content roots as you say would work, but would require either changing our architecture on the web servers, or having the development environment not match the server environments.

So if the current solution works, then that is the best. However, I note the additional comment from Andriy which may be an issue.

I note that other IDEs do not have this problem. That is, content outside of the project causes no problem with debugging. Specifically, Zend Studio 5.5 (which I have used since 2005 and am trying hard to break away from), as well as Komodo IDE and NetBeans both of which I am currently evaluating along with PHPStorm. PS has the lead at the moment, mainly because it is "snappier".

0
Comment actions Permalink
That is, content outside of the project causes no problem with debugging. Specifically, Zend Studio 5.5 (which I have used since 2005 and am trying hard to break away from), as well as Komodo IDE and NetBeans both of which I am currently evaluating along with PHPStorm.

PhpStorm is an IDE and not just advanced text editor. It is based around projects and it must properly index files in order to work with them. Therefore file outside of project (completely unknown, I mean -- files added as External Libraries will still work fine) cannot be used during debugging (as it will treat them as plain text).

PhpStorm just works slightly differently to other IDEs -- like it or not, just differently. However this does not mean that you cannot debug such files.

It's all because PhpStorm is based on IDEA platform which is still quite-heavily I would say (my personal opinion, of curse) Enterprise/Java-oriented, and some features/nuances applicable to PHP only are either not implemented yet .. or cannot be easily implemented as it requires changes on platform-wide level (in some situations it's a good thing and in some -- not at all). Plus -- feature that is important to you may not be important at all to me (and via versa) -- but devs have to consider all sides (end users as well as marketing side -- never ending "battle" between bug fixing/enhancing existing functionality and introducing new features when number of resources/developers is rather limited -- everything needs to be balanced).

However, I note the additional comment from Andriy which may be an issue.

Try how it works yourself first -- no need to speculate. In any case -- I do not see any more-or-less big problems here. Even if somethign does not fully supported (like mentioned Open file in browser), it does not matter, as there almost always is a workaround or feature is simply not required (I, for example, do not use it and it is useless when nice URLs are used instead ... or when all URLs are routed via single entry point -- index.php).

0

Please sign in to leave a comment.