Jump to content


Photo

Vendo arquivos PHP rodando http://localhost no navegador no Notepad++

php localhost wamp tutorial

  • Faça o login para participar
Nenhuma resposta neste tópico

#1 ShZlot

ShZlot

    12 Horas

  • Moderadores
  • 121 posts
  • Sexo:Masculino
  • Localidade:Bahia

Posted 05/08/2015, 01:14

Eu tinha um problema chato. Quando eu queria visualizar um arquivo .php no Notepad++ ele executa no navegador, mas como arquivo local e não no Wamp.
 
Eu ia no menu Executar -> Lounch in Chrome
Attached File  01.png   35.91KB   0 downloads
 
 
E no navegador aparece assim:
Attached File  02.png   19.14KB   0 downloads
 
Então dei uma pesquisada de como configurar o Notepad++ para quando executar no navegador abrir o arquivo com http://localhost/_testes/testing.php e vi que pelo Npp não conseguiria. Então eu criei um script PHP que redireciona o arquivo de local para HTTP.
 
Na pasta raiz do domínio localhost crie o arquivo lh.redirect.php e nele coloque o código abaixo.
Como eu uso Wamp, o meu é C:/wamp/www/.
 

<?php
/*
 * Por Ennio Sousa http://uid.me/shzlot
 * 05/08/2015
 *
 * file:///C:/wamp/www/path/file.php
 * http://localhost/path/file.php
 * use http://localhost/lh.redirect.php?path=$(FULL_CURRENT_PATH)
*/
$BASE_DIR = "C:\wamp\www";
$BASE_URL = "http://localhost"; // http://127.0.0.1


// verificar se o paramentro path foi informado
$PATH_WIN = (isset($_GET['path']))? $_GET['path'] : 0 ;

if($PATH_WIN){
	echo $PATH_WIN;
	$PATH_HTTP = str_replace($BASE_DIR, $BASE_URL, $PATH_WIN);
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: $PATH_HTTP");
}
else{
	echo "Não foi informado o parametro <b>path=</b>";
}
?>

 
Depois você vai precisar abrir a pasta C:\Users\[seu usuário]\AppData\Roaming\Notepad++\ . Para facilitar segure o botão do menu iniciar e depois pressione a letra R e cole URL a baixo no Executar do Windows
 

%USERPROFILE%\AppData\Roaming\Notepad++\

 

Attached File  03.png   9.51KB   0 downloads
Abra o Bloco de Notas como administrador e depois abra o arquivo shortcuts.xml para editar.

Procure por

chrome &quot;$(FULL_CURRENT_PATH)&quot;

 

E substitua por

chrome &quot;http://localhost/lh.redirect.php?path=$(FULL_CURRENT_PATH)&quot;

 
 

<NotepadPlus>
    <InternalCommands />
    <Macros>
        <Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
            <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
            <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
        </Macro>
    </Macros>
    <UserDefinedCommands>
        <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Ver no Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;http://localhost/lh.redirect.php?path=$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="70">safari &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/%20$(CURRENT_WORD)</Command>
        <Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">http://www.google.com/search?q=$(CURRENT_WORD)</Command>
        <Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">http://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
        <Command name="Open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
        <Command name="Open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -nosession -multiInst</Command>
        <Command name="Send via Outlook" Ctrl="yes" Alt="yes" Shift="yes" Key="79">outlook /a &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    </UserDefinedCommands>
    <PluginCommands />
    <ScintillaKeys />
</NotepadPlus>

Feche e abra novamente o Notepad++ para ter efeito as alterações.
 
Quando você for executar novamente, o URL a ser aberto será http://localhost/lh.redirect.php?path=C:/wamp/www/_testes/testing.php

E então o script irá redirecionar para http://localhost/_testes/testing.php
Attached File  04.png   19.2KB   0 downloads


Trabalho desenvolvendo no melhor e mais completo CMS do tipo SaaS. Conheça você também e crie um site grátis no uCoz.






Veja alguns posts relacionados com: php, localhost, wamp, tutorial

1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq