How to get PHP working in Brackets? - php

I'm almost finished my first website. All that's left is the contact which I will do with PHP. So far I have been using Brackets for coding HTML5 and CSS.
From my research I understand that I need a server to run PHP so I installed XAMPP. I have relocated my project inside the htdocs folder of XAMPP, however when I try to open up my PHP page in Brackets' live preview I get this.

Found out whats wrong, I had to go to project settings in brackets and adjust the directory to match the location of the project inside the xampp directory.

Related

How to access php project from localhost (Apache)

I know this question may first appear to be a duplicate of others, but I'm asking this because I have WordPress installed in my /var/www/html directory. I was learning WordPress a couple of years ago before creating a website and never used it again.
Well, I'm creating a php project using PhpStorm and testing in my browser. I'm following a tutorial so I can configure my databse (phpmyadmin), and the instructor keeps going to his localhost, which displays the directory structure as seen here:
Since I have WordPress on my localhost, navigating to that takes me to my WordPress installation, which is not what I want to access.
I would rather ask this question on here before I potentially break my Apache configuration, so how can I access this project? Do I need to remove WordPress completely? It would be nice to keep it for future testing since I'm slowly getting into making plugins.
What are your suggestions? I can't really say much as far as "what have you tried?" since I don't know where to begin.
Running in Chrome within my PhpStorm IDE takes me to localhost:63342/projectName/respectivePhpFileName.php, but I can't access it outside of the IDE yet.
Any help would be appreciated.
Just move your Wordpress outside your htdocs folder...I think he is using something like XAMPP so in that way is very easy to do it, because the folder without an index will be detected as a directory not a Wordpress URL (correct me if I'm wrong). So if that doesn't works, just go to your htdocs (/var/www/html or opt/lampp/htdocs in Linux) directory (or where your wordpress is stored) and move it to other folder (like My documents) where you can backup it, and that's it, you can create that folder and keep following that tutorial.

Using gulp livereload with XAMPP

I been using gulp for front-end development lately and I find it very helpful.
I use XAMPP in windows for making PHP website some of which sometime include database operations.
Now, I have used gulp-livereload and gulp-connect for starting a server for front-end but then it won't process the PHP files.
All I want to do is, PHP livereload with database access. Like livereloading but via XAMPP's server(since it can process PHP).
yes, I have found a temporary solution for now.
See, it's just temporary but as long as you write PHP correct, you will get the work done. Let me tell you how I do it.
Though right off the start I want to tell you that this is not a proper way to approach this, you should use some MVC framework.
Anyway,
I have XAMPP installed under Windows 8.1 and XAMPP's htdocs is in my "C" Drive.
I then create a folder inside "htdocs" in which I put all my frontend + backend code.Basically, gulpfile.js is at the root, then there is a components folder in which all front-end sources reside. There is another folder at root called "www" inside which I put my index.php.
Then I load gulp-livereload instead of gulp-connect and I add the livereload.listen(); method and Tags in all the php files I want to reload.
Works very fine except when PHP throws an error, untill you correct that error, you have keep reloading the page manually.

How to live preview PHP using MAMP

I am creating a WP theme (for personal use only) and I need to be able to preview PHP files.
Here's where I'm at so far:
I use Adobe's Brackets.
I have a server on Bluehost.
I have downloaded FileZilla and linked it to my bluehost server.
I have created a directory on my bluehost server: /public_html/wp-content/themes/Cookie
I have downloaded an FTP Sync extension in Brackets, and synced it to the root directory of my theme (/public_html/wp-content/themes/Cookie).
I have installed MAMP on my mac (although never used it and have no idea what to do next).
I have contact Adobe Brackets and they have said this: "If you have a MAMP (or other PHP server) set up, you just need to change the File->Project Settings"
But I have no idea what to do now I have downloaded MAMP.
As you can probably tell, I'm a bit of a noob so please explain things delicately :)
Thanks in advance!!!!
download Wordpress from wordpress.org, install it locally on your MAMP, it shoud have a folder called www or data, reading the docs is recommended. Then, download your theme from your hosting and to the wp-content/themes/ folder, now start a new project, it's gonna be easier.
When your theme is ready, upload it to the server again.
Hope this helps.
I had the same issue but figured it out with the help of your question.
So this is for brackets newcomers like myself :)
Guide for Mac:
Setting up Server
Download and install MAMP
Go to MAMP Preferences
Change the "document root to your project
Brackets Setting:
Open Brackets
Make sure the "Enable Experimental Live Preview" IS OFF! (File > Enable...)
Go to File > project setting
copy and paste this default MAMP server address (http://localhost:8888/) [or change according to your MAMP setting]
Thats it you have got your live preview up and running!

My PHP code is commented out

Before everything happened, I was running this wordpress install for developing themes using xampp. But I decided to upgrade the memory of this machine from 2GB to 6GB since I need extra room for applications. I back-up my code in a separate partition by copying them. Since I have a 32bit OS at the time, I format the computer and installed a 64bit version. All is well and fine the OS side.
When I setup my web dev environment something goes wrong.
When I imported my htdocs back, first by just fully copying them to a new fresh install of xampp and notice that all of the codes that put are not working. My CI code is displaying my PHP code in the browser. My theme in wordpress is also commenting out my PHP code when I view the source. The themes included in my fresh wordpress install works so there's something I am missing here.
From the looks of it, the php is being executed properly since anything that I install works. Just that the ones that came from a previous xampp is not.
Open up the php.ini file and set short_open_tag = On. Then restart apache.
If you are opening a local script directly in the web browser, maybe through your editor, double-clicking on the file or dragging and dropping the file ito the browser - it will be treated as HTML only.
Instead, open the file by typing... http://localhost/your-file.php into the address bar. I personally create a projects folder in the htdocs folder and then create a bookmark for... http://localhost/projects/ and this will display all my projects that are saved into my projects folder.
Note: if you changed the mail port for the Apache server, you will need to add that to the path as well. eg. If your main port is 8888, your would do this... http://localhost:8080/your-file.php
I had the same problem and this worked for me. Good Luck
For me, it was because the file was named as ".html". You must have an extension ".php"

HTML project in netbeans

Ok I just installed netbeans for php and i'm trying to create a new project for html/javascript but I only see php project there.
I can create a php project and just create html files inside of it, but it makes me define a project path to localhost. So when I try to run my project, it directs to localhost instead of my project's root folder.
Sorry I'm new to this piece of software so excuse any ignorance.
It redirects because php requires a server. If you have plan to make a project for html and javascript alone you can try with some good html editors like dreamweaver or other IDE's.

Categories