Using Brackets for PHP files
Asked Answered
B

4

12

I currently have wampserver running and I'm trying to do live preview of a php file using Brackets.io. However when I click live preview I'm getting

Project settings for: Getting Started
Live preview base URL: ______________

I'm following this tutorial on running PHP scripts. My php file is in C:/wamp/wwww/php_proj1/php1.php so I've been trying to put this in my "Base URL"

http://localhost/php_proj1/php1.php

However everytime when I type that and enter it, it just asks me for the "Live Preview Base URL" again and nothing happens. I also tried putting the URL in my 'File->Project settings' and that also didn't work. I'm just running a basic php script that echos some words.

It works when I manually type

http://localhost/php_proj1/php1.php

in my Chrome URL but not when I use Bracets live preview.

What am I missing or doing wrong? Do I need to config anything in my wampserver? I've just started learning php and using wampserver so I'm not entirely sure what I'm doing wrong.

Thanks!

EDIT: I'm following these 2 tutorials on doing this and it's just not working for me. tutorial 1 and tutorial 2

EDIT2: Found my mistake.. I did not do File->Open Folder to open the folder that I was working on... Thanks to everyone that helped me with this, I will definitely not make this mistake again. sigh

Beguine answered 9/1, 2015 at 8:18 Comment(7)
IIRC, you need a Chrome plug-in to allow live debugging from BracketsMccain
What exactly do I need? Can you explain a little bit more? I can do live preview when I run my html files, just can't seem to make it work for PHP.Beguine
can you try this "./php_proj1/php1.php" as your base url?Warman
I tried it, and again, the dialog just closes and opens up again and asking me to input the "Live preview base URL" all over again.Beguine
have you followed this? github.com/adobe/brackets/wiki/…Banish
this should work: github.com/adobe/brackets/wiki/Brackets-Server-Smoke-TestsBanish
@Mccain You don't need a Chrome plugin to use Live Preview in BracketsBettencourt
B
4

Found my mistake. I did not do File->Open Folder to open the folder that I was working on...

Beguine answered 17/1, 2015 at 6:3 Comment(0)
D
6

The Live Preview Base Url should be set to the same url that you would use to launch your project in a browser.

So if you have a project in C:/wamp/wwww/php_proj1/ you would launch that project in a browser by entering http://localhost/php_proj1/php1.php therefore that is what Brackets is expecting to be entered into the Base Url field minus the actual script file name.

Remember the DocumentRoot of localhost is pointing to the folder C:/wamp/www/

So enter

http://localhost/php_proj1/

into the dialog that requests the Base Url.

Assuming you are editing the file php1.php at the time you clicked the Live Preview icon that is the script that will be run in the browser.

Oh and of course you have to have WAMPServer and therefore Apache up and running when you do this as it is running the code through Apache so that the PHP code can be interpreted.

Debbradebby answered 11/1, 2015 at 19:34 Comment(5)
I found another tutorial on this and it didn't say to have Apache. I'm just wondering do I have to have it? And again, I tried putting in the Base url you have but it's not working and the dialog just keeps showing up asking for the Base Url over and over again no matter what I put.Beguine
You have to use LIVE PREVIEW is you have PHP Code in our project, and Live Preview means run on a real web server i.e. WAMPServer or something similiarDebbradebby
It's still not working :( This is driving me madddddddBeguine
Are you sure that WAMPServer is running and the W icon is green?Debbradebby
Yes, is says it's running and the W icon is green.Beguine
B
4

Found my mistake. I did not do File->Open Folder to open the folder that I was working on...

Beguine answered 17/1, 2015 at 6:3 Comment(0)
S
2
  1. Try the same thing but with a simple HTML file.

  2. Try launching your project with PHP's built-in server. Open a terminal/cmd window and go to the folder php_proj1. Now execute php -S localhost:8000. Now set your Live preview path to http://localhost:8000/. If this one does work, then there may be a problem with Wamp.

Now remember that no matter what, you're not supposed to contain a file in the Live Preview path, but only a folder path. When you contain it, you get to this URL: http://server/file.php/file.php (double) and that's not exactly what you want...

If none of these work - there may be a problem with either your computer, Brackets, Chrome, or both. Try to reinstall them (Brackets first).

Stein answered 15/1, 2015 at 14:55 Comment(1)
I was able to live preview a html file inside my php_proj1 folder . And I'm not sure how to do your #2 since my cmd isn't set up to use php. Could it be that I still need to config my WAMPserver? Since Brackets is able to run html fine but just not phpBeguine
D
0

My two cents, is the name of the project php_proj1 ? If not you'll have to use http://localhost/ as your base URL.

Also (When you are using Brackets) check the content of the Chrome Network tab. F12 Developer Tools -> Network -> Filter -> Documents

Try to investigate the URLs, probably that'll give you some insight

Diller answered 15/1, 2015 at 15:14 Comment(2)
My php1.php file is in the folder 'php_proj1' which is in my C:\wamp\www\php_proj1 When I check the content of the chrome network tab nothing was recorded or there wasn't anything there.Beguine
You'll have to reload the page after activating the chrome developer tools. Regarding the project name, this image shows that the project name in that tutorial is WWW similarly if your project name is WWW your Base URL is http://localhostDiller

© 2022 - 2024 — McMap. All rights reserved.