Sublime Forum

Open In Browser for PHP files

#1

If I edit an html file and right click on it, I can “open in browser”. If I edit a php file and right click on it, there is no “open in browser” option. Is this something I can configure please?

I’m using sublime text 3 (for almost three weeks now!) and am finding the configuration rather confusing.

I’ve followed a blog post to configure the build system for PHP, but that only compiles the code and displays the raw HTML in an ST3 window.

Thanks
Steve

0 Likes

#2

first you install sidebar enhancement plugin and then right click on project > **Edit Preview URLS **
SideBarEnhancements.json file will be open there you set your project location in below format

{ "/opt/lampp/htdocs/parixan":{ "url_testing":"http://localhost/parixan", "url_production":"http://127.0.0.1/parixan" }, }

now using F12 and Ctrl F12 will open it in browser.

see also : github.com/xkeshav/sublime/blob … ettings.md

0 Likes

#3

Thanks xkeshav, a definite step forward.

Unfortunately, this opens the php file in another editor (webuilder) for some reason. I’ll play with those settings and see if I can stumble on the right ones. I suspect that the first parameter (/lamp) is wrong for my system - which is a Windows system - so I’ll mess with that.

Thanks
Steve

0 Likes

#4

Progress. I now have to deal with the 404 error! At least it’s opened the browser this time.

Thanks for the help.

Steve

0 Likes

#5

Working!

 {
    "E:\\Projects\\WebSites\\theoldbloke.com":{
        "url_testing":"http://localhost:8081/theoldbloke.com",
        "url_production":"http://www.theoldbloke.com"
    }
}

So, the first value is the path to the project on my local system where the source files are stored. The url_testing is the URL that we want opened when we open in the browser. This has to correspond to the web-site that I have defined in IIS. The important things to get right (which I didn’t) was getting the right port number at both ends and getting the right path that the site maps to. The path was the point of failure as I browsed to the folder containing the source files - it actually needed the parent folder as it appended the sub-folder name.

Strange, when you actually read the error messages carefully they’re sometimes quite useful. Seeing “theoldbloke.com” twice in the path was a not-entirely subtle clue.

Steve

0 Likes

#6

[quote=“xkeshav”]first you install sidebar enhancement plugin and then right click on project > **Edit Preview URLS **
SideBarEnhancements.json file will be open there you set your project location in below format

{ "/opt/lampp/htdocs/parixan":{ "url_testing":"http://localhost/parixan", "url_production":"http://127.0.0.1/parixan" }, }

now using F12 and Ctrl F12 will open it in browser.

see also : github.com/xkeshav/sublime/blob … ettings.md[/quote]

You have to remove the last comma or it won’t work … cost me a few hours :smiley: but on the other hand - without this thread I would have never came to the solution.

0 Likes