I am busy reading: PHP Web Services, 2nd edition
And I am on chapter 2 whereby I am trying to make a GET request to a PHP file that is a simple search form, the GET request code is as follows and uses PHP's stream handling with contexts to perform the request:
<?php
$url = "http://localhost:63344/HTTP Verbs/SimpleSearchForm.php";
$data = [
"category" => "technology",
"rows" => 20
];
$get_addr = $url . '?' . http_build_query($data);
$page = file_get_contents($get_addr);
echo $page;
The search form is as follows:
<html>
<head>
<title>GET Form</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
</head>
<body>
<div style="margin: 20px">
<h1> A GET Form</h1>
<?php if (empty($_GET)): ?>
<form name="search" method="get" class="pure-form pure-form-stacked">
Category:
<select name="category">
<option value="entertainment">Entertainment</option>
<option value="sport">Sport</option>
<option value="technology">Technology</option>
</select>
Rows per page: <select name="rows">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
<input type="submit" value="Search" class="pure-button pure-button-primary"/>
</form>
<?php else: ?>
<p>Wonderfully filtered search results</p>
<?php endif; ?>
</div>
</body>
</html>
These are examples straight from the book and I am trying to run it using PhpStorm's built-in server. I can open the search form as expected however the built-in server just hangs when I try to make the GET request with the other script.
I was just wondering if anyone has experienced this and if so then what can I do to remedy it?