Prior to developing and running PHP programs and applications we need to first setup and configure the environment for it. This can be done using the following methods :
Setting up a local PHP environment
If you want to develop and run PHP applications on your local PC you have to set up the environment for PHP on your system. This involves three steps:
- Installing a PHP web server on which the PHP scripts will execute
- Installation of a PHP Engine
- Installing a database which can integrate with PHP Eg: MySQL
We can install these either individually one by one, or together as a part of pre-configured packages. It is better to use pre-configured packages because your environment will be set up and ready to use with just a few clicks.
We can choose the pre-configured package that is compatible with our Operating system (Linux or Windows). Some commonly used pre-configured packages for PHP are XAMPP and WAMP.
WAMP preconfigured package
Wamp Server is a Windows web development environment. It allows you to create web applications with Apache, PHP and a MySQL database. It will also provide the MySQL Administrative tool PhpMyAdmin manage databases easily using a web browser.
The WAMP installer can be downloaded from the following link
https://bitnami.com/stack/wamp/installer
Choose the installer appropriate for your version of Windows. Once the installer has downloaded completely double-click on the exe. Within a few clicks, the WAMP stack is setup and ready to use and you can commence writing your first .php program.
XAAMP pre-configured package
XAAMP is an Apache distribution which provides a web development environment. It is more popular because it is compatible with different operating systems like Windows and Linux. It allows users to create a web application using Apache, PHP and MySQL.
The XAMPP installer appropriate for your OS can be downloaded from the following link
https://www.apachefriends.org/download.html
Once the installation file has finished downloading we can commence installation by double-clicking the downloaded .exe file. Within a short span of time and a few clicks the XAMPP environment is ready to use.
On a Web Host
If are using a web host, which has activated PHP support, to develop your PHP web application you do not need to install anything.
You can start working on the .php files by placing them in the web directory. The server will process the PHP files.
Nowadays almost all web hosts offer free PHP support and upgrades as PHP is free and one of the most widely used web development languages.