Configuring Notepad ++ to run php on localhost?

I am trying to get the Run-> Launch With Firefox option; to open the file that I am viewing in Notepad ++ at http://127.0.0.1:8080/currentfile.php , but instead it just opens to the current file directory in Firefox .. I tried to edit the shortcut of the xml file in the Notepad + directory +, I closed Notepad ++ down and edited the XML file using the usual Notepad, and when I started the Notepad ++ backup, it does not show the entered settings. How do I change the settings for loading the local host, not the file directory in Firefox?

+4
php notepad ++ localhost
Sep 24 2018-11-11T00:
source share
6 answers

well two things

  • you edited the wrong file, I assume that you are using Windows Vista / 7, so the real settings files are in the folder C: \ Users \ user \ AppData \ Roaming \ Notepad ++

  • I do not think that notepad ++ has a variable containing only half the address

Value: now the variable $ (FULL_CURRENT_PATH) == file: /// C: /server/htdocs/pages/example.php is used

therefore, you do not have a variable containing only these /example.php pages.

so i think it's impossible

but just save the page and refresh it after editing

+2
Sep 24 '11 at 2:40
source share

Here's a quick and dirty fix for running php files, even if they are in subdirectories inside your document root. In shortcuts.xml:

 <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 

Then create the file "redirect.php" in the root document of your web server:

 <?php $root = $_SERVER['DOCUMENT_ROOT']; $file = str_replace('\\', '/', $_GET['file']); $file = str_replace($root, '', $file); header("Location: http://localhost{$file}"); 
+9
Dec 31 '13 at 10:10
source share

If you save the PHP file directly to the www WAMP directory (without subfolders), you can execute it by selecting the "Run ..." command and paste into this line:

 firefox.exe "http://localhost/$(FILE_NAME)" 

This is not great, but it will help you debug in jiffy.

+2
Feb 14 2018-12-12T00:
source share

I know this is an old question, but:

but. Gneid solution works well. However, Windows may require some modification, so DOCUMENT_ROOT will be replaced before the slash is replaced. Otherwise, no replacement will be made, and the $ file will be displayed in the same way as the original path and file name, except that backslashes are canceled.

Since I'm testing in multiple browsers, I modified all the relevant lines in C: \ Users [username] \ AppData \ Roaming \ Notepad ++ \ shortcuts.xml:

 <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> <Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="70">safari &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 

Then create the file "redirect.php" in the network root directory as follows:

 <?php $root = $_SERVER['DOCUMENT_ROOT']; $file = $_GET['file']; $file = str_replace($root, '', $file); $file = str_replace('\\', '/', $file); header("Location: http://localhost{$file}"); ?> 
+1
Jun 02 '14 at 2:54 on
source share

Forgot sign / after local

 <?php $root = $_SERVER['DOCUMENT_ROOT']; $file = $_GET['file']; $file = str_replace($root, '', $file); $file = str_replace('\\', '/', $file); # Was forgotten mark / header("Location: http://localhost/{$file}"); ?> 
0
Dec 09 '14 at 13:11
source share

this is the code that worked for me:

 <?php $root = $_SERVER['DOCUMENT_ROOT']; $file = $_GET['file']; $file = str_replace($root, '', $file); $file = str_replace('\\', '/', $file); $file = str_replace('C:/wamp64/www/', '', $file); // Cause 'localhost' is equal to 'C:/wamp64/www/' in my case. header("Location: http://localhost/{$file}"); ?> 

Thanks to everyone ..

0
Oct 13 '16 at 19:02
source share



All Articles