How to create a PHP project
How to create a PHP project

How to create a PHP project

Hello dear readers! How are doing? Hope you all are well. Today from this post we are going to discuss another interesting topic. That is how to create a PHP project. Most of students who just started to learn web development struggle with this topic. Since they don’t know much about this. From this post you can grab all the things you needed to know about how to do a PHP project. After reading this you can start your own PHP project. We have provided so many posts related to PHP project development. Please check our posts. These posts contains details to develop an entire PHP project from module to module. How to create a Login form is one them. Check others also. Let’s get started.

What is a PHP project?

Firstly we will see what is a PHP project. PHP is a scripting language. We can use it to web development. PHP is a loosely type language. That means you don’t need to write data types like Java. We can omit them and write. This will boost and ease software coding. The projects we build using PHP is a PHP project. Usually these projects are web based projects.

What is the Difference of HTML and PHP

Earlier I said PHP use for web development specially. Then you might confused then HTML used for what. HTML is also use to create web pages and web development. Yet HTML is different from PHP. HTML is a markup language. It is not a scripting language. PHP is a scripting language. From HTML we can create a web page. Sending request from one web page to another, pass data these things we can’t do using HTML. To write logics like IF, Switch we can’t write using HTML. For those we can use PHP.

Can we code HTML inside PHP file

Yes. We can write. Actually that is the thing what we do. In a web development we create a PHP file. Inside a PHP file we can type HTML. When we write PHP code we write them inside the PHP tags.


What do we need to do a PHP project

As usual we need some pre requisites to start a PHP project.  Fulfilling these requirements are the first step of how to do a PHP project. Here we will discuss how to create a PHP project with basics. In other words there are frameworks available for PHP projects. If you use one these needs might slightly different.

XAMPP/WAMPP for localhost

PHP project is a web project. That means something run in the internet. Therefore we need a server. We can’t buy a server for development work. Therefore we use something call local server. It will give us the ability to see how our website will look in a server environment or web. So have to use a software for that. Examples for those are XAMPP server, WAMPP server. I usually prefer XAMPP. You can go to the website and download the file and install XAMPP.

When you install XAMPP I will suggest one thing for you. If you are using SQL server and XAMPP both in your machine firstly install the XAMPP. Then phpMyAdmin can run using port number 3306. After you can install SQL server with having port number 3307. This can remove most of the issues you might face when using both environment for the development in one machine.

Text editor to code

For this you have multiple options. You can use IDE or simple text editor. If you like you can use a IDE like Adobe dreamviewer. Either you can use a text editor like vscode, sublime. I use sublime text editor because I prefer simple.

After you have these things you can start to create a PHP project.

How to create a PHP Project

Step 01 – creating the folder structure

Firstly you have to create the folder structure. After you install XAMPP server there will be a folder created in the C drive. So first you have to create your project folder in there. Follow these steps for that.

  • Go to C drive
  • Open XAMPP folder
  • Go inside htdocs
  • Create a new folder inside htdocs
  • Give your project name for that
How to create PHP project in htdocs
How to create PHP project in htdocs


Step 02 – Run XAMPP server

  • If you have a desktop shortcut for XAMPP double click it. If not search for XAMPP from search bar and open it.
  • After XAMPP control panel opens click start button in front of Apache.
  • Then click start button in front of MySQL to run database server.
How to run XAMPP server
How to run XAMPP server

After you run the Apache and MySQL server XAMPP control panel will look like this.

XAMPP control panel
XAMPP control panel

Step 03 – Open project in text editor

If you are using sublime you can open the sublime editor. How to open project in sublime editor. Here are the steps.

  • Open sublime editor.
  • Go to project.
  • Click add folder to project.

After that you can see your project folders in the right side panel.

Step 04 – Open web project in localhost

  • Firstly you have to open a web browser. You can open chrome, Firefox or windows explorer web browsers.
  • Then in the URL type localhost/your project name.
  • Then your projects folders will show up. You can select the page you want to see.

That’s all. You have done everything. These are the steps you need to follow to create a PHP project. Apart from this there is something else also. That is you might want to connect a database to your project. For that follow below steps. This will teach you how to create a database in phpMyAdmin and connect it to the PHP project.

How to create a database for PHP project

  • Firstly what you have to do is click admin button in front of MySQL in the XAMPP control panel.
  • Then the phpMyAdmin admin panel will open.
  • If this is open in the windows explore and you are not familiar you can copy the URL and pate it on the chrome.
How to run phpMyAdmin
How to run phpMyAdmin


Always open the web page and the database in the same web browser. This make coding easier and less errors.

phpMyAdmin interface
phpMyAdmin interface


  • After admin panel open click new.
  • Then type a name for the database and click create.
How to create a new database in phpmyAdmin
How to create a new database in phpmyAdmin


  • Then you can see the newly created database in the write hand side.

How to create a table in a new database in phpMyAdmin

  • Left click on your newly created database.
  • Type your table name inside create table.
  • Then click Go.
How to create a table in phpMyAdmin
How to create a table in phpMyAdmin

How to insert data into a table in phpMyAdmin

Left click on the table you created.

Click insert tab from the tabs.

Fill the data and click Go.

How to insert data to a table in phpMyAdmin
How to insert data to a table in phpMyAdmin

How to connect database to the PHP project

For this you need to type the code in the PHP file. Firstly create a PHP has a meaningful name which implies it is a file include the db connection. Here we create the database by using class concept. We can easily retrieve database by calling database method. This will ease the coding. Because of that we create the static variables. Add following code to your file.

<?phpclass Connection{
public static function conn(){$host ="localhost";
$uname = "root";
$password = "";
$dbname = "db_name";$dbobj = new mysqli($host,$uname,$password,$dbname);if($dbobj->connect_errno){
echo("db connection error <br>");
echo("Error text: ".$dbobj->connect_error);
return $dbobj;}}


To retrieve the database object for querying. Firstly you have to include the database PHP file to the PHP file you write the code. Then after that type this code to get the db object. After this you can type your query code as usual like fetch_assoc().



So here is the all about how to create a PHP project. We learned so many things apart from that also today. If you want to learn how to create other PHP modules as I said please read other related posts.  You can find the explanation of connection class for PHP from this post.  Validate login form and database connectivity. If you like this post please share this. You can give your suggestions about these articles. You can comment using the below comment box. Either you can go to our contact us page and write us. Then we will bring you another interesting topic. Till then goodbye to all.

Audy Ranathunga

Audy Ranathunga, Author of myexamnote is our most experienced author. She has been working as a blog post writer for 4 years. She joined with myexamnote before 1 year ago and she has contribute lots of valuable posts for readers.

This Post Has 2 Comments

  1. Avatar
    Dollie Colli

    I like this post, enjoyed this one thankyou for putting up.

    1. Audy Ranathunga
      Audy Ranathunga

      Thank you so much.

Leave a Reply