Confused about remote server configuration

I have a development setup which I don't think is too exotic, however I cannot figure out how to make it work in PhpStorm. First off, my "production" server is using shared hosting. The file structure is like this:

/foo/bar/private
/foo/bar/private/php/


/foo/bar/public_html
/foo/bar/public_html/index.html
/foo/bar/public_html/...<the rest of the web-accessible site>

foo/private is not accessible via the web, only the tree rooted at /foo/bar/public_html is web-accessible. Or, in other words, there is *no* URL that can get to anything under /foo/bar/private

Because some of my php code contains sensitive data I'd prefer to keep those sensitive bits like database passwords outside of the web-accessible portion and instead put it into /foo/bar/private. Currently the only PHP code I plan to have in there are defines setting up some constants. But I'd still like to be able to set breakpoints in any code in the PHP files in /foo/bar/private in my development copy. I might decide to put some class files in there, for example.

I would to duplicate this structure in my php project and on my remote development server (which is really just a VirtualBox VM). I just can't figure out a combination of settings that can get me there. It looks like there cannot be any file in the project outside of public_html. I did see something about "multiple content roots" but the discussion there was a bit confusing.

Some parts of the help pages I found confusing include:

"3. Correspondence between the project root folder, the folder on the server to copy the data from the project root folder to, and the URL address to access the copied data on the server. This correspondence is called mapping."

 

To me this suggests that the project root folder must be web-accessible. However, I'd like to make /foo/bar the project root. The root of the web-accessible part of this is /foo/bar/public_html, and thus they are not the same.

 

Can this be done?

7 comments
Comment actions Permalink

Hi there,

I do not understand your issue / what your problem is.

Your setup is very common (e.g. a typical Laravel/Symfony/Yii/etc project)

Make your project root (where you open the project) to be /foo/bar/

/foo/bar/public_html will be your website root. You can mark it as Resource Root to have paths resolved in CSS/HTML

/foo/bar/private is just an ordinary project folder.

Please describe the actual issues / problems that you need to resolve in details. Screenshots are more than welcome.

0
Comment actions Permalink

Thank you Andriy. The problem I'm having is that the terminology in your online help doesn't match the terminology used in phpstorm. Or, perhaps I'm not looking in the right place. Here are the screen shots where I'm attempting to configure the remote server.

 

Ignore the "Local item ... not found", I've changed the path to protect proprietary aspects. Basically /Users/jkp/psweb/dev/web1/private maps to /foo/bar/private and /Users/jkp/psweb/dev/web1/public_html maps to /foo/bar/public_html.

You wrote "Make your project root (where you open the project) to be /foo/bar/" but the phrase "project root" does not appear in the the screenshots. I would assume that is what is called the "Root Path" in screenshot #1.

"/foo/bar/public_html will be your website root. You can mark it as Resource Root to have paths resolved in CSS/HTML".

Neither of the phrases "website root" nor "resource root" appear in the screenshots. The dialog has basically five fields. None of them are called "project root" or "website root" or "resource root". The five fields are "Root path", "Web server URL", "Local path", "Deployment path", and "Web path". When I configure the server the way the screenshots show and "Run" the project from public_html/index.html the browser pops up with the URL https://192.168.56.107/public_html/index.html, which is incorrect. If everything was correctly configured the URL would be https://192.168.56.107/index.html.

0
Comment actions Permalink

Thanks for clarification. Now I see what you need.

First of all: the "project root" and "resource root" -- it's about the actual project setup -- it's not related to the deployment.

"Project root" is the root folder of your project as seen in Project View panel (red bordered area). Please note: my project here used here is a very basic one and has just 2 folders. "web" is the actual website root (content accessible via web browser).

The "Resource root" -- is the "web" folder on my screenshot (your would be "public_html") -- the folder icon is purple (the big arrow points there). You can mark it as Resource Root via "Right click menu | Mark Directory as..." or via "Settings/Preferences | Directories"

Now to the actual problem:

>When I configure the server the way the screenshots show and "Run" the project from public_html/index.html the browser pops up with the URL https://192.168.56.107/public_html/index.html, which is incorrect. If everything was correctly configured the URL would be https://192.168.56.107/index.html.

What you need to do here is to add 2nd path mapping for your Deployment (your 2nd screenshot). Leave original mapping as is -- it should be correct to upload files  from the project root. Use "Add new mapping" button to create new entry:

  • Local path: path to your local public_html folder
  • Deployment path: "/public_html/" (without quotes)
  • Web path: just "/" (without quotes)

At the end it should look like this (my "web" should be your "public_html")

The above is enough for IDE to build URLs for files from "public_html" folder as if it's the website root.

2
Comment actions Permalink

That worked! Thank you so much Andriy!

 

0
Comment actions Permalink

Ugh, this is now no longer working. I am not certain what I changed to break this. I have the mappings just as you have shown but I'm once again getting  https://192.168.56.107/public_html/index.html when I "Run" or "Debug". Any ideas on how I might discover what I changed to break this again?

0
Comment actions Permalink

@Greg Stark

>Any ideas on how I might discover what I changed to break this again?

Must be your settings .. as it still works just fine here in few projects (2020.2 version)

The very first that comes into my mind: double check that the deployment entry is marked as Default for this project and that the paths are correct/not excluded etc. Try deleting and recreating that 2nd mapping entry just in case.

If still the same: please post deployment and directories related screenshots/maybe even a small screencast: maybe it will show up there...

0
Comment actions Permalink

Ok, thanks Andriy, for some reason in the Run/Debug configuration the URL was set to https://192.168.56.107/public_html/index.html. When I deleted the "public_html/" component everything worked as before.

 

Thank you for your assistance Andriy.

0

Please sign in to leave a comment.