Brackets Php

How to use Brackets for coding PHP

Brackets Code Editor is best for Front End Development i.e. HTML, CSS & JavaScript.

From Brackets 1.14 version, the Brackets code editor supports PHP using the PHP Language Server.

Brackets has Syntax Highlighting and other important features.

Important features of Brackets for PHP

  1. Code Hint – Shows PHP coding hints to the user
  2. Parameter Hint – During the function call, it shows the hints about the parameter
  3. Jump to definition – Jump to the location where the class/selection is defined in PHP. Shortcut is Ctrl + J
  4. Linting – Diagnoses the PHP code while typing or saving. Brackets does it by showing Linting errors at the bottom
  5. Find references – A file referencing feature that can find the list of files where a code/text is coded. For this, simply Right Click on the particular code and click on ‘Find All References”. The shortcut key is Shift + F12
  6. Can find all Document Symbols in current document – Shortcut is Ctrl + T
  7. Helps to find all the project Symbols – Shortcut is Shift + Ctrl + T

Prerequisite to run PHP on Brackets

HTML, CSS and JavaScript can easily run in the browser as these are client side languages.

On the other hand, PHP is an Open Source Server Side Scripting Language. So, you need to install a local web-server such as Apache or ngix server in your computer to run PHP.

If you are looking for a server in cloud, then Amazon Cloud or Nitrous is a good option.

You can install any web server that supports PHP & MySQL.

There are free software packages like XAMPP, WAMP, MAMP, etc which has inbuilt Apache.

TutorialBrain recommends to install XAMPP as it is the most popular Apache distribution software package that supports PHP,  MYSQL, MariaDB and Perl.

Install XAMPP and setup PHP

Follow these steps to run PHP code in your local computer –

  1. Install XAMPP from the official website here. By default, it will install in C drive(C:\xampp)
  2. Go to XAMPP Control Panel & start the Apache server. Optionally, you can also start MYSQL if you would require a Database connection with MYSQL.
  3. Locate the folder with the name as htdocs  inside the XAMPP installation.
  4. Create your PHP Project Folder here with any name such as myphpproject.
  5. Go to Brackets editor and navigate to File -> Open Folder and open the myphpproject folder. The shortcut is Ctrl + Alt + O.
  6. Set the Base URL. Go to File -> Project settings  and set the project URL. In most of the computers, the localhost is http://localhost/. So, the base URL for your project will be http://localhost/myphpproject
  7. Create a new PHP file inside this folder and write your PHP code
  8. Save the PHP file with any name such as index.php. It is important to save the file with a .php extension
  9. Click on ‘Live Preview’ and you are ready to run the PHP files in your computer

Is it mandatory to run Live Preview?

No, it is not mandatory to use the “Live Preview” feature of Brackets if you have installed a local server like XAMPP, WAMP, MAMP, etc.

Suppose, you have your Apache installation and you created your project folder under the ‘htdocs‘ folder. Now, you need to simply start your Apache server and type your localhost URL such as – http://localhost/index.php on your browser.

Now, whenever you do your code changes, you have to refresh the browser for changes to reflect.

Extra Tips

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.

Brackets File Format Icon

Popular PHP Brackets Extension

  1. QuickDocsPHP Good extension to show the PHP documentation quickly.
  2. Indentator – Extension to Re-indent the PHP code as per your current indentation settings. To use this, go to Edit -> Indent Document. Shortcut is Ctrl + Alt + i.
  3. PHP SmartHints – Intelligent & robust code hinting extension for PHP in Brackets. This extension has a PHP autocomplete feature which is extremely helpful. The Code Hints include Function, Variables, etc. As Brackets has inbuilt Code hint mechanism now, this extension is not necessary but few developers are still using it.
  4. PHP Code Quality Tools – Tool that shows PHP Linting by using multiple code analysis tools. Now, PHP has the Linting feature inbuilt so this extension is not necessary. If you do not like the inbuilt Linting of Brackets, then you can use this tool.

To refer most popular extensions, we recommend you to read our best tutorial on ‘Brackets Extensions‘.

Tutorials for all brains!