Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Dom Smith
Dom Smith
3,091 Points

Using PHP in Adobe Brackets Code Editor?

Hello Guys,

I'm current developing using Adobe Brackets, and plan to create a user login using PHP and a MySql database. However I'm struggling to find a way to get php working with Brackets as it doesn't automatically recognize the .php file format.

the error i'm getting is "To launch live preview with a server-side file, you need to specify a Base URL for this project"

Has anyone else stumbled upon this problem, and if so how did you solve it?

Thanks in advance

Dom Smith
Dom Smith
3,091 Points

Didn't find a solution, so a answer would still be grateful I just ended up using the WebMatrix software which comes with PHP MySql packages included. Far from ideal but a get around at least.

7 Answers

Have you avoided using something like MAMP on purpose? It's always best to test in a real browser!

Dom Smith
Dom Smith
3,091 Points

No I haven't it looks like it would have saved me a lot of time. I'll have to check it out at some point and see if its what I need.

Waldo Alvarado
Waldo Alvarado
16,322 Points

In Brackets go to File ---> Open Folder... (Ctrl + Alt + O) open up the folder containing your php files (i.e. index.php), then open up your index.php, click live preview and type in http://localhost/. This should work for you.

Also keep in mind that you really don't need to use the Live Preview feature in Brackets if you are using a local server. I currently have my project in the htdocs folder of my Apache installation. By merely starting up Apache, typing in my localhost URL and clicking refresh whenever I make changes, Brackets still works like a charm.

Brackets with PHP works for me. You might have to go to the lower-right, and click on "HTML" (or whatever other language it says), and change it to PHP:

Dom Smith
Dom Smith
3,091 Points

Cheers for the response, I've already got that set to php, in the Live preview I got the error

"To launch live preview with a server-side file, you need to specify a Base URL for this project"

you haven't come across this before?

Oh. Yes, I've had that. Sorry, but I don't know how to fix it :(

One thing: I used to use Brackets, but just a couple days ago started using C9. I haven't done any PHP with it yet, but they probably have a live preview for it (that works ;), and I'd recommend them if you ever feel like moving your code editing to the cloud.

You need to install a server in your OS like wamp, XAMPP, or other of your preference, after install, just start apache, and check if the server is started typing localhost in your browser, after started you need to put your project in the server folder (it'll change depending of server that you've installed), then when the Brackets ask you the url just type the location of your project like "http://localhost/yourproject" without quotes.

it's all.

sorry for my english.

Diego Hernandez
Diego Hernandez
11,468 Points

Hi! I had the same trouble and this worked perfectly.

You can install MAMP (a program for running PHP as a local host). This video explains the installation process: For Mac: https://teamtreehouse.com/library/setup-your-local-development-environment-2 For Windows: https://teamtreehouse.com/library/setup-your-local-development-environment

Once you do all that is told in the video go to brackets-> live preview -> and place the base url like this: http://localhost:8888/foldername

foldername is the name of the folder where your css, html and php files are.

That simple!

Lacey Brown
Lacey Brown
5,340 Points

Another recommendation is using the application CodeKit. You just enter in your server info, and your browser refreshes upon each save. I love Brackets, but I prefer Live Experimental Preview vs. manually refreshing the browser after each save.