* Help with PHP setup
@ 2018-07-15 20:10 taariqq
2018-07-19 23:57 ` Jean-Christophe Helary
2018-07-20 23:10 ` Bob Proulx
0 siblings, 2 replies; 17+ messages in thread
From: taariqq @ 2018-07-15 20:10 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I am trying to set emacs up so that I can use it for PHP development.
What I am looking for:
a) A way to open the files, via my vagrant or lampp setup, in the browser.
b) Update the view in the browser as I save changes to the file in the editor.
c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
Not experienced at this stuff and would appreciate a little help.
Brackets is awesome at this stuff but does not have a good Git integration. VS Code is good at Git and other stuff but the 'preview' end is lacking.
I have tried the 'impatient-mode' and found it jittery. I do not necessarily need 'Live-Preview' ... just update upon save.
If I can configure Emacs I won't have to bother learning other editors and can concentrate on the learning.
Sincerely,
Taariqq
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-15 20:10 Help with PHP setup taariqq
@ 2018-07-19 23:57 ` Jean-Christophe Helary
2018-07-20 2:32 ` Van L
2018-07-20 23:10 ` Bob Proulx
1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-19 23:57 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 16, 2018, at 5:10, taariqq <taariqq@gmail.com> wrote:
>
> I am trying to set emacs up so that I can use it for PHP development.
>
> What I am looking for:
> a) A way to open the files, via my vagrant or lampp setup, in the browser.
> b) Update the view in the browser as I save changes to the file in the editor.
> c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
>
> I have tried the 'impatient-mode' and found it jittery. I do not necessarily need 'Live-Preview' ... just update upon save.
>
> If I can configure Emacs I won't have to bother learning other editors and can concentrate on the learning.
Same here. Any hint on how to do a live update in localhost or somewhere where the php code can be run ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-19 23:57 ` Jean-Christophe Helary
@ 2018-07-20 2:32 ` Van L
2018-07-20 4:14 ` Jean-Christophe Helary
0 siblings, 1 reply; 17+ messages in thread
From: Van L @ 2018-07-20 2:32 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
>> I am trying to set emacs up so that I can use it for PHP development.
>>
>> What I am looking for:
>> a) A way to open the files, via my vagrant or lampp setup, in the browser.
>> b) Update the view in the browser as I save changes to the file in the editor.
>> c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
>>
>> I have tried the 'impatient-mode' and found it jittery. I do not necessarily need 'Live-Preview' ... just update upon save.
>>
>> If I can configure Emacs I won't have to bother learning other editors and can concentrate on the learning.
>
> Same here. Any hint on how to do a live update in localhost or somewhere where the php code can be run ?
At a guess, are you trying to do the following?
- You have a host: php-dev.example.com
- You have a file there /-:php-dev.example.com:/usr/local/site/info.php
- You have ssh terminal access using `ssh php-dev.example.com`
- You want to add the line `<pre>x</pre>` in info.php? and see the result in Firefox web browser as
https://php-dev.example.com/info.php
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-20 2:32 ` Van L
@ 2018-07-20 4:14 ` Jean-Christophe Helary
2018-07-20 5:47 ` Van L
0 siblings, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-20 4:14 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 20, 2018, at 11:32, Van L <van@scratch.space> wrote:
>
>
>>> I am trying to set emacs up so that I can use it for PHP development.
>>>
>>> What I am looking for:
>>> a) A way to open the files, via my vagrant or lampp setup, in the browser.
>>> b) Update the view in the browser as I save changes to the file in the editor.
>>> c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
>>>
>>> I have tried the 'impatient-mode' and found it jittery. I do not necessarily need 'Live-Preview' ... just update upon save.
>>>
>>> If I can configure Emacs I won't have to bother learning other editors and can concentrate on the learning.
>>
>> Same here. Any hint on how to do a live update in localhost or somewhere where the php code can be run ?
>
> At a guess, are you trying to do the following?
>
> - You have a host: php-dev.example.com
>
> - You have a file there /-:php-dev.example.com:/usr/local/site/info.php
>
> - You have ssh terminal access using `ssh php-dev.example.com`
>
> - You want to add the line `<pre>x</pre>` in info.php? and see the result in Firefox web browser as
> https://php-dev.example.com/info.php
Something like this except I'm working on localhost with a running Apache server etc.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-15 20:10 Help with PHP setup taariqq
2018-07-19 23:57 ` Jean-Christophe Helary
@ 2018-07-20 23:10 ` Bob Proulx
2018-07-20 23:37 ` Jean-Christophe Helary
[not found] ` <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 17+ messages in thread
From: Bob Proulx @ 2018-07-20 23:10 UTC (permalink / raw)
To: help-gnu-emacs
taariqq wrote:
> I am trying to set emacs up so that I can use it for PHP development.
I use emacs for PHP development.
> What I am looking for:
> a) A way to open the files, via my vagrant or lampp setup, in the browser.
> b) Update the view in the browser as I save changes to the file in the editor.
> c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
I hate to post something that says it can't be done. Because almost
always when someone says something can't be done it actually can be
done and other people prove that to be true. But reading the above
makes me think that if someone does make that work that it would be
"icky".
The web browser program is so far removed from the editing program
that your desire to connect them together makes this feel "icky" to
me. Although maybe you can get part way there with a browser plugin.
You didn't say if you were using Firefox, Chromium, or one of the
other browsers. Knowing which browser you are using will undoubtedly
be important at some point.
> Not experienced at this stuff and would appreciate a little help.
The way I personally operate is to edit the files with emacs on my
local system in my local sandbox. I usually have a local php server
running in another terminal "php -S localhost:3000 -t root" or similar
(the "root" will be instance specific). I make changes. I then
switch over to my web browser (which may be emacs w3m or emacs eww, or
it may be Firefox or Chromium, either way) and reload the page.
Seeing the result then I make more changes in emacs. Back and forth.
I check the output of the php server to check on any errors that may
be logged there. I tolerate no spurious output and fix any error or
warning that appears. Working this way is very easy.
If I switch to a different page then I do need to manually track to
that new page using either emacs w3m or Firefox/Chromium or whatever.
But then I am on the new page. I only need to reload the page. I
must emphasize that most of the time when I am developing that using
emacs as the browser through emacs w3m is usually sufficient. (I find
the w3m form interaction user interface to be tedious however.)
I always develop locally in my local sandbox. Then commit to version
control into my development branch. Then test on my victim server.
Then push to production. This glosses over a lot of details.
When I check into git I use the command line. Usually using the most
awesome "git add -p ..." to split my changes into appropriate chunks
of changes. That's a killer feature for me. I never picked up the
habit of the emacs magit git interface but everyone else says very
good things about it and eventually I will try it.
Bob
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-20 23:10 ` Bob Proulx
@ 2018-07-20 23:37 ` Jean-Christophe Helary
2018-07-21 3:53 ` Bob Proulx
[not found] ` <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-20 23:37 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 21, 2018, at 8:10, Bob Proulx <bob@proulx.com> wrote:
>
> taariqq wrote:
>> I am trying to set emacs up so that I can use it for PHP development.
>
> I use emacs for PHP development.
>
>> What I am looking for:
>> a) A way to open the files, via my vagrant or lampp setup, in the browser.
>> b) Update the view in the browser as I save changes to the file in the editor.
>> c) Switch the view in the browser as I switch from file to file and continue to see the updates upon save.
>
> I hate to post something that says it can't be done. Because almost
> always when someone says something can't be done it actually can be
> done and other people prove that to be true. But reading the above
> makes me think that if someone does make that work that it would be
> "icky".
On a different thread I just asked how to call the file in the front buffer without explicitly referring to its name and Eli was nice enough to point at the obvious answer: buffer-file-name.
So we can actually have a function that replaces the path part of the file by a localhost url and run a command that opens that in the default browser.
Nothing icky about it, we just need the correct parameters to put that together.
Jean-Christophe
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-20 23:37 ` Jean-Christophe Helary
@ 2018-07-21 3:53 ` Bob Proulx
2018-07-21 13:17 ` Jean-Christophe Helary
2018-07-22 13:56 ` Jean-Christophe Helary
0 siblings, 2 replies; 17+ messages in thread
From: Bob Proulx @ 2018-07-21 3:53 UTC (permalink / raw)
To: help-gnu-emacs
Jean-Christophe Helary wrote:
> So we can actually have a function that replaces the path part of
> the file by a localhost url and run a command that opens that in the
> default browser.
Won't that stack up new tabs endlessly? Or at least every time the
function runs, which as I understand it would be every time the buffer
was saved to a file?
> Nothing icky about it, we just need the correct parameters to put
> that together.
As I said, someone will prove that it is possible. :-)
Bob
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-21 3:53 ` Bob Proulx
@ 2018-07-21 13:17 ` Jean-Christophe Helary
2018-07-22 13:56 ` Jean-Christophe Helary
1 sibling, 0 replies; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-21 13:17 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 21, 2018, at 12:53, Bob Proulx <bob@proulx.com> wrote:
>
> Jean-Christophe Helary wrote:
>> So we can actually have a function that replaces the path part of
>> the file by a localhost url and run a command that opens that in the
>> default browser.
>
> Won't that stack up new tabs endlessly? Or at least every time the
> function runs, which as I understand it would be every time the buffer
> was saved to a file?
That's a possibility. On macOS I can see how some AppleScript glue can help target a given tab or do something similar. I don't know how natively scriptable are browsers on Linux or Windows so a solution targeting a given tab is unlikely to be portable...
>> Nothing icky about it, we just need the correct parameters to put
>> that together.
>
> As I said, someone will prove that it is possible. :-)
... knock on wood ...
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-21 3:53 ` Bob Proulx
2018-07-21 13:17 ` Jean-Christophe Helary
@ 2018-07-22 13:56 ` Jean-Christophe Helary
2018-07-22 15:20 ` Jean-Christophe Helary
1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-22 13:56 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 21, 2018, at 12:53, Bob Proulx <bob@proulx.com> wrote:
>
> Jean-Christophe Helary wrote:
>> So we can actually have a function that replaces the path part of
>> the file by a localhost url and run a command that opens that in the
>> default browser.
>
> Won't that stack up new tabs endlessly? Or at least every time the
> function runs, which as I understand it would be every time the buffer
> was saved to a file?
>
>> Nothing icky about it, we just need the correct parameters to put
>> that together.
>
> As I said, someone will prove that it is possible. :-)
On macOS it seems the "open " command targets the same tab so I don't seem to have to be worried about that:
(defun myLocalhostTest ()
"saves and opens the file opened in the current buffer into localhost"
(interactive)
(save-excursion
(save-buffer)
(setq myRoot "http://localhost:8888/")
(setq myFile (file-name-nondirectory (buffer-file-name)))
(setq myTestCommand (concat "open " myRoot myFile))
(shell-command myTestCommand)))
The above trivial code needs improvements to handle cases where the file is not at the root of localhost, but that can wait for now :)
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-22 13:56 ` Jean-Christophe Helary
@ 2018-07-22 15:20 ` Jean-Christophe Helary
2018-07-22 15:36 ` Noam Postavsky
0 siblings, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-22 15:20 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 22, 2018, at 22:56, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>
> On macOS it seems the "open " command targets the same tab so I don't seem to have to be worried about that:
>
> (defun myLocalhostTest ()
> "saves and opens the file opened in the current buffer into localhost"
> (interactive)
> (save-excursion
> (save-buffer)
> (setq myRoot "http://localhost:8888/ <http://localhost:8888/>")
> (setq myFile (file-name-nondirectory (buffer-file-name)))
> (setq myTestCommand (concat "open " myRoot myFile))
> (shell-command myTestCommand)))
>
> The above trivial code needs improvements to handle cases where the file is not at the root of localhost, but that can wait for now :)
I found a way to update the output for "normal" php files but as I work on a WordPress site where final urls do not reflect the local file path I'm finding that my "trick" doesn't work:
(defun myLocalhostTest ()
"saves and opens the file opened in the current buffer into localhost"
(interactive)
(global-set-key (kbd "s-r") 'myLocalhostTest)
(save-excursion
(save-buffer)
(setq myLocalRoot "/Applications/MAMP/htdocs/")
(setq myServerRoot "http://localhost:8888/")
(setq myFile (substring (buffer-file-name) (length myLocalRoot)))
(setq myTestCommand (concat "open " myServerRoot myFile)) ;; this "open " command only works on macOS... I don't know equivalents on Linux.
(shell-command myTestCommand)))
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-22 15:20 ` Jean-Christophe Helary
@ 2018-07-22 15:36 ` Noam Postavsky
2018-07-22 15:44 ` Jean-Christophe Helary
0 siblings, 1 reply; 17+ messages in thread
From: Noam Postavsky @ 2018-07-22 15:36 UTC (permalink / raw)
To: Jean-Christophe Helary; +Cc: Help Gnu Emacs mailing list
On 22 July 2018 at 11:20, Jean-Christophe Helary <brandelune@gmail.com> wrote:
> (setq myTestCommand (concat "open " myServerRoot myFile)) ;; this "open " command only works on macOS... I don't know equivalents on Linux.
By the way, xdg-open is approximately equivalent on many GNU/Linux
distros; you might also consider using Emacs'
browse-url-default-browser function, which tries looking for other
browsers if the former fails.
https://manned.org/xdg-open.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-22 15:36 ` Noam Postavsky
@ 2018-07-22 15:44 ` Jean-Christophe Helary
2018-07-22 15:53 ` Jean-Christophe Helary
0 siblings, 1 reply; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-22 15:44 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 23, 2018, at 0:36, Noam Postavsky <npostavs@gmail.com> wrote:
>
> On 22 July 2018 at 11:20, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>
>> (setq myTestCommand (concat "open " myServerRoot myFile)) ;; this "open " command only works on macOS... I don't know equivalents on Linux.
>
> By the way, xdg-open is approximately equivalent on many GNU/Linux
> distros; you might also consider using Emacs'
> browse-url-default-browser function, which tries looking for other
> browsers if the former fails.
Nice hint :) Thank you !
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Help with PHP setup
2018-07-22 15:44 ` Jean-Christophe Helary
@ 2018-07-22 15:53 ` Jean-Christophe Helary
0 siblings, 0 replies; 17+ messages in thread
From: Jean-Christophe Helary @ 2018-07-22 15:53 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
> On Jul 23, 2018, at 0:44, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>
>> On Jul 23, 2018, at 0:36, Noam Postavsky <npostavs@gmail.com> wrote:
>>
>> On 22 July 2018 at 11:20, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>>
>>> (setq myTestCommand (concat "open " myServerRoot myFile)) ;; this "open " command only works on macOS... I don't know equivalents on Linux.
>>
>> By the way, xdg-open is approximately equivalent on many GNU/Linux
>> distros; you might also consider using Emacs'
>> browse-url-default-browser function, which tries looking for other
>> browsers if the former fails.
>
> Nice hint :) Thank you !
So, I guess I have something working for my case now:
(defun myLocalhostTest ()
"saves and opens the file opened in the current buffer into localhost"
(interactive)
(global-set-key (kbd "s-r") 'myLocalhostTest)
(save-excursion
(save-buffer)
(setq myLocalRoot "/Applications/MAMP/htdocs/")
(setq myServerRoot "http://localhost:8888/")
(setq myFile (substring (buffer-file-name) (length myLocalRoot)))
;; the 2 lines below are useful for some WP files, but I'm not sure yet how the whole thing works
(if (equal (car (cdr (split-string myFile "/"))) "wp-content")
(setq myFile (concat (car (split-string myFile "/")) "/" (file-name-nondirectory (buffer-file-name)))))
;; end of the WP special case
(setq myURL (concat myServerRoot myFile))
(browse-url-default-browser myURL)))
That works for all the php/html files I have, at least those that are in similar relative position vs the localhost root.
I'm sure there are better ways to achieve a similar result, but that's good enough for now :) Thank you all.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>]
* Re: Help with PHP setup
[not found] ` <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>
@ 2018-07-21 3:38 ` Rusi
0 siblings, 0 replies; 17+ messages in thread
From: Rusi @ 2018-07-21 3:38 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, July 21, 2018 at 5:07:36 AM UTC+5:30, Jean-Christophe Helary wrote:
> On a different thread I just asked how to call the file in the front buffer without explicitly referring to its name and Eli was nice enough to point at the obvious answer: buffer-file-name.
I have this in my emacs setup:
(define-key minibuffer-local-map (kbd "C-f")
(lambda ()
(interactive)
(let ((file-path-maybe (buffer-file-name
(window-buffer (minibuffer-selected-window)))))
(insert (if file-path-maybe
(file-name-nondirectory file-path-maybe)
"%")))))
It emulates vi's replacement of % with filename with a more emacsish replace
C-f with filename
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2018-07-22 15:53 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-15 20:10 Help with PHP setup taariqq
2018-07-19 23:57 ` Jean-Christophe Helary
2018-07-20 2:32 ` Van L
2018-07-20 4:14 ` Jean-Christophe Helary
2018-07-20 5:47 ` Van L
2018-07-20 7:46 ` Jean-Christophe Helary
2018-07-20 7:52 ` Van L
2018-07-20 23:10 ` Bob Proulx
2018-07-20 23:37 ` Jean-Christophe Helary
2018-07-21 3:53 ` Bob Proulx
2018-07-21 13:17 ` Jean-Christophe Helary
2018-07-22 13:56 ` Jean-Christophe Helary
2018-07-22 15:20 ` Jean-Christophe Helary
2018-07-22 15:36 ` Noam Postavsky
2018-07-22 15:44 ` Jean-Christophe Helary
2018-07-22 15:53 ` Jean-Christophe Helary
[not found] ` <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>
2018-07-21 3:38 ` Rusi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).