How to visualise/ preview a PHP homepage in BBEdit?

209 views
Skip to first unread message

Omar KN

unread,
Mar 10, 2024, 10:35:41 AM3/10/24
to BBEdit Talk
This topic has been mentioned before, but I was looking for a not too difficult solution.

Has the come any news about this issue?

/
with best regards,
Omar KN, Stockholm, Sweden

Omar KN

unread,
Mar 10, 2024, 1:04:54 PM3/10/24
to BBEdit Talk
Today I installed and “Successfully started `php@8.1` (label: homebrew.mxcl.php@8.1)”

What is the next step to preview a PHP page in Safari?

Malcolm Fitzgerald

unread,
Mar 10, 2024, 3:42:26 PM3/10/24
to BBEdit Talk

User Terminal to open the the folder that contains your PHP files.

Type:

php -S localhost:8080 & ; open -a Safari.app localhost:8080

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/f8b66a71-c9c9-4b38-8334-2336a0eec8c3n%40googlegroups.com.

Omar KN

unread,
Mar 10, 2024, 4:10:16 PM3/10/24
to bbe...@googlegroups.com
Safari can't connect to the server "localhost".

You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/d2JfkgJcCAY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/ADB8268B-3075-4056-8979-72937DD3CF28%40notyourhomework.net.

Darren Duncan

unread,
Mar 10, 2024, 9:16:33 PM3/10/24
to bbe...@googlegroups.com
PHP 8.3 is the latest version and has a lot more features and a longer support
window of 3 years, versus less than 1 year remaining for 8.1; why use 8.1?

Also, if you desire to have a web page, do you want vanilla PHP or do you want
an actual application framework? If you use Laravel for example, it takes care
of a lot of stuff for you.

-- Darren Duncan

Omar KN

unread,
Mar 11, 2024, 4:15:50 AM3/11/24
to BBEdit Talk
The sole purpose for having php is to be able to view the BBEdit preview in the browser.

Although I installed php, the command is not found, so something is missing.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

php -S localhost:8080 & ; open -a Safari.app localhost:8080

[1] 19195

zsh: command not found: php

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

What could be missing here?

/
with best regards,
Omar KN, Stockholm, Sweden

Omar KN

unread,
Mar 11, 2024, 4:28:54 AM3/11/24
to BBEdit Talk
>do you want vanilla PHP or do you want 
an actual application framework? If you use Laravel for example, it takes care 
of a lot of stuff for you.

Interesting, but my needs in this respect are very simple. The browser preview.
If I cannot get it going through BBEdit , then some alternative would necessary.
Thank you Darren!
(And vanilla PHP, application framework, are unknown concepts for me. :-)

On Monday 11 March 2024 at 02:16:33 UTC+1 Darren Duncan wrote:

Malcolm Fitzgerald

unread,
Mar 11, 2024, 8:14:58 AM3/11/24
to BBEdit Talk

Sorry,

I assumed that you already had a working installation of PHP. Get PHP installed properly, you'll find plenty of How-to videos at Youtube.


Malcolm

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.

James Reynolds

unread,
Mar 11, 2024, 11:27:24 AM3/11/24
to bbe...@googlegroups.com
You probably don't have brew's install path in your terminal path. If you have no idea what this means you probably need to learn a bit more about developing with the Terminal. Just search YouTube for "macos terminal tutorial" and "getting started with php macos". There's tons of webpages on this too.

James Reynolds

Omar KN

unread,
Mar 11, 2024, 11:37:52 AM3/11/24
to bbe...@googlegroups.com
Yes, I remember I could not separate for this step to make it 2 commands, if you could do it:

==> Next steps:

- Run these two commands in your terminal to add Homebrew to your PATH:

    (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/okn/.zprofile

    eval "$(/opt/homebrew/bin/brew shellenv)"


One commad would probably be:

echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"'

but the second?

eval "$(/opt/homebrew/bin/brew shellenv)

Should I create /Users/okn/.zprofile first?


If this is too difficult to answer, there is still YouTube …

/
with best regards,
Omar KN, Stockholm, Sweden


You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/d2JfkgJcCAY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/9C097133-54B2-4AF1-AF59-8477D822F025%40gmail.com.

James Reynolds

unread,
Mar 11, 2024, 12:09:39 PM3/11/24
to bbe...@googlegroups.com
Omar,
It isn't that your question is difficult to answer. I was a music student decades ago and I asked a somewhat famous (in my neck of the woods) organist if she could give me organ lessons. I wasn't a pianist. She told me to learn piano first and then ask her for lessons. I was pretty put off by it because she came off as pretty rude but I understand why she did it. I hope I'm not coming across as rude now.

Someone on this list might have the time to walk you through the steps but I don't. I also didn't want to just leave you hanging so I wanted to say something in case nobody responds. I think if you go watch some tutorials and read some webpages and you still can't figure it out, I'm pretty sure many people, including myself, would be happy to help you out.

Here's a little help. The '>>' in `(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/okn/.zprofile` will create /Users/okn/.zprofile. View the file by typing `cat /Users/okn/.zprofile` and make sure `eval "$(/opt/homebrew/bin/brew shellenv)"` is at the end of the file. Then open a new Terminal window and php should be in your PATH.

Again, I'd go watch some videos and read as much as you can until everything I just said makes sense to you.

James Reynolds
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/AD6B7FD7-24BB-411A-AF59-A44CEBE16A0E%40gmail.com.

Malcolm Fitzgerald

unread,
Mar 11, 2024, 3:39:47 PM3/11/24
to bbe...@googlegroups.com


On 12 Mar 2024, at 4:37, Omar KN wrote:

> Yes, I remember I could not separate for this step to make it 2 commands, if you could do it:
>
> ==> Next steps:
> - Run these two commands in your terminal to add Homebrew to your PATH:
> (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/okn/.zprofile
> eval "$(/opt/homebrew/bin/brew shellenv)"
>
> One commad would probably be:
>
> echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"'
>
> but the second?
>

The two commands are on the first line. They are separated by the semicolon. The second line is displaying the output of the two commands.

Make use of the many good tutorials available on youtube.

Malcolm

Omar KN

unread,
Mar 11, 2024, 4:25:06 PM3/11/24
to bbe...@googlegroups.com
Some success!
(from a good tutorial!)

1.

Safari reads the php file which is in:

/Users/okn/phpfolder/tj.php



2.
However:

/Users/okn/SitesMacHD/liv/chu/e/rrue_e.php



http://127.0.0.1:8000/Users/okn/SitesMacHD/liv/chu/e/rrue_e.php


The requested resource /Users/okn/SitesMacHD/liv/chu/e/rrue_e.php was not found on this server.


And this is the correct path!


Any idea what’s going on here?

/okn

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


>I hope I'm not coming across as rude now.

Not at all :-)

> walk you through the steps

My assumption was that I’ve almost arrived at the goal.

Make use of the many good tutorials available on youtube.

Yes.



James Reynolds

unread,
Mar 11, 2024, 4:31:07 PM3/11/24
to bbe...@googlegroups.com
Omar,
If you are accessing your php file using Safari and http://127.0.0.1:8000/, that means you are running a web server. Your web server will have a DOCROOT or DocumentRoot directory. This directory maps It is probably /Users/okn/phpfolder/. If /Users/okn/phpfolder/ is your DOCROOT, then http://127.0.0.1:8000/ will look for /Users/okn/phpfolder/index.html (or index.php). Because /Users/okn/SitesMacHD isn't in your DOCROOT, your web server wont show it. This is to prevent people from looking at things like your private files. You'd have to put rrue_e.php inside of your DOCROOT.

James Reynolds
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/CB0ABE1C-88CF-4B12-BB05-461AC2780F07%40gmail.com.

Message has been deleted

Darren Duncan

unread,
Mar 11, 2024, 5:04:42 PM3/11/24
to bbe...@googlegroups.com
A key issue here is you haven't even explained what you mean by "BBEdit preview"
in your context, or I haven't understood it.

Normally a "BBEdit preview" is when you are editing a file with what is intended
to be human-readable documentation in some kind of markup language, such as
Markdown or POD or HTML, and you use BBEdit's "Preview" function to see how that
renders.

Whereas, if you want to run a program such as PHP which happens to output a web
page, and you want to see that web page in a browser, then that is not what
"Preview" is for, and instead that is what "Run" is for.

Can you clarify, what kind of thing are you making and what do you expect the
result to be. Please give a simple example file.

Are you making a PHP program and want to display its result. Or is the thing
you want to "Preview" actually not a PHP program but you were thinking to use
PHP to solve your problem to "Preview" some other kind of thing.

Please give an example file.

-- Darren Duncan
Message has been deleted

Omar KN

unread,
Mar 12, 2024, 3:25:53 PM3/12/24
to BBEdit Talk
Hello Darren,


>what kind of thing are you making


The **RUN** command does everything needed here, than you.

 → Go To:  Top menu > #! > Run 

/okn
(Thank God it has been solved, thank you everyone who assisted!)
Reply all
Reply to author
Forward
0 new messages