Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Brackets for PHP files

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

like image 291
user3128376 Avatar asked Jan 09 '15 08:01

user3128376


People also ask

Can I write PHP in brackets?

Brackets supports many file formats such as Html, CSS, JavaScript, PHP, Perl, Python, etc. While working with a PHP file, make sure that Brackets shows the file format as PHP at the bottom. If it shows any other format, then change it to PHP.

Is bracket good for web development?

Brackets provides better features for web design. It's an Adobe product that features simple integration with other common design tools, such as Photoshop. Brackets also features Creative Cloud access, making it easy to manage an entire front end project.

Is brackets good for coding?

Brackets is the best text and code editor around. We use it daily for fixing HTML and CSS and for opening any text/code files.


2 Answers

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.

like image 124
RiggsFolly Avatar answered Sep 22 '22 10:09

RiggsFolly


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

like image 23
user3128376 Avatar answered Sep 24 '22 10:09

user3128376