RoCk RoCk - 5 months ago 25
PHP Question

How To Test OOP Php Functions In POSTMAN Rest API

I'm practicing making

php
script in an
OOP
format. And I'm about to test my
methods
in my
php
script. The problem is, how do I specifically test those
methods
that I made?


POSTMAN

http://localhost/tryhard/OOP/dbConnectClass.php
- Where should I place them the
method
name?

Answer

Postman is build for building, testing and documenting APIs. If you want to test your method You must have to create a PHP file, import the class file, create object and call the method.

You can't directly call methods in Postman.

Create file like this:

Filename: testapi.php

<?php

import('dbConnectClass.php');

$dbConnect=new DBConnect(); // Assuming class name is DBConnect()
$returnvalue=$dbConnect->methodName();
echo $returnvalue;

// You can return output as JSON here.    

?>
Comments