How to call URL of any other website in PHP

Views: 41872

I need to Call a  MEAN stack app into an Apache server,

Here is how I might call the mean app. I am designing a platform that divides a monolith app into micro-services with high availability.

To the URL first set the PHP resource:

$ch = curl_init();

direct example: CURL_EXEC:

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser

// close cURL resource, and free up system resources
$page = file_get_contents("");

This does require FOpen which some web hosts disable and some web hosts will allow FOpen, but not allow access to external files. You may want to check where you are going to run the script to see if you have access to External FOpen. You can also use file_get_contents to access REST APIs:

$payload = file_get_contents('');


Or if you just want a simple URL GET then:

$lines = file('');


Leave a Reply