PHP Environment Setup


August 23, 2021, Learn eTutorial
1491

PHP is an interpreted and object-oriented scripting language. PHP can be written on a simple text editor. Web server applications are used to run the program. 

What are the requirements for PHP programming?

  • IDE
  • Web Server
  • Database
  • AMP

What is an IDE? 

IDE (Integrated Development Environments) are those applications that are used to develop other applications. IDE’s can perform all the functions required to develop an application. An IDE includes Source Code editor, Compiler, Debugger, and other built-in tools.

Which are the most popular IDEs for PHP?

  • VS Code
  • Eclipse
  • NetBeans
  • Atom
  • IntelliJ IDEA
  • PHPStorm
  • Xcode
  • Brackets
  • Komodo Edit
  • WebStorm

What is a web server?

To load a web page written in PHP requires a web server application. PHP is supported on almost every web server application. The most commonly used web server application is Apache Server.

PHP Database 

PHP can be integrated with most of the databases which are currently used in the industry namely MySQL, PostgreSQL, Oracle, and Microsoft SQL Server. MySQL database is the most commonly used database. MySQL is an open-source relational database management system.

What is AMP?

AMP denotes the software stack which is used for the PHP installation. In AMP, A stands for “Apache” M stands for “MySQL” and P stands for “PHP”. The most commonly used AMPs are:

How to install XAMPP:

Even though XAMPP supports every operating system we are showing the steps to install XAMPP on windows

  1. Download the XAMPP application according to the system specification.
    How to install XAMPP Step 1
  2. After the successful download run the .exe file and grant the required permissions for the installation.
    How to install XAMPP Step 2
  3. Select all the required components and click next
    How to install XAMPP Step 3
  4. Select the folder where to install the xampp on the system or set it as the default path and click next
    How to install XAMPP Step 4
  5. Click on the Next button
    How to install XAMPP Step 5
  6. Click on the Next button to install the xampp
    How to install XAMPP Step 6
  7. Click on the finish button to complete the installation process
    How to install XAMPP Step 7
  8. Select the language
    How to install XAMPP Step 8
  9. Now XAMPP is ready to use. Click on the start button of Apache and MySQL   
    How to install XAMPP Step 9
  10. if there is no error occurred XAMPP will run successfully
    How to install XAMPP Step 10

If XAMPP run successfully the PHP programs can be run on the localhost.

How to run a PHP program?

  1. Open any text editor for this program we are using notepad
    How to run a PHP program? : Step 1
  2. Write the PHP code in the notepad. For example, we are writing the code to print Hello World
    How to run a PHP program? : Step 2
  3. To save the file click on save or save as menu in file menu or use the shortcut ctrl + s or ctrl + shift + s
    How to run a PHP program? : Step 3
  4. Now select the xampp folder from the drive
    How to run a PHP program? : Step 4
  5. Then select the htdocs folder from the xampp folder
    How to run a PHP program? : Step 5
  6. Then create a new folder for saving the PHP file. Here we are creating a folder in name as the demo
    How to run a PHP program? : Step 6
  7. Now we have to give a name to the PHP file, here we are saving in name as “first_program” with the extension “.php” (a PHP file should always be saved with the extension of .php). Then change the save as type to “all files” and save the file by clicking on the save button.
    How to run a PHP program? : Step 7
  8. After saving the file we should open the control panel of XAMPP 
    How to run a PHP program? : Step 8
  9. if there is no error occurred the window will open as below. Then we have to click on the start button of Apache and MySQL
    How to run a PHP program? : Step 9
  10. If it successfully starts Apache and MySQL we can see green color on Apache and MySQL and PID corresponding to it.
    How to run a PHP program? : Step 10
  11. After the successful start of Apache and MySQL open the localhost on any web browser according to your preference. Now we can see the folder we created with the name of “demo” and on opening the folder we can see the PHP file we created in the name of “first_program” 
    How to run a PHP program? : Step 11
  12. On opening the PHP file the program will run and the output will be visible on the screen   
    How to run a PHP program? : Step 12