Did you get to this function direct from a route or by some other method?
is your 'Going to view Folder' shown?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
My problem is simple. On the latest version of laravel, my controller function is not returning to the given view. here is all I have.
my controller's function:
public function findBBDirect($pageNumber) {
$token = $this->accessToken;
$headers = ['Authorization: Bearer ' . $token];
$curl = curl_init();
$validReturn = true;
$url = "https://my.url.com"
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => TRUE,
CURLINFO_HEADER_OUT => TRUE,
CURLOPT_URL => $url,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_HEADER => TRUE,
CURLOPT_RETURNTRANSFER, TRUE
]);
if (curl_errno($curl)) {
echo 'Error:' . curl_error($curl) . "<br>";
} else { echo " all good<br>"; }
$resp = curl_exec($curl);
$header_size = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
$header = substr( $resp, 0, $header_size );
$body = substr( $resp, $header_size );
$data = json_decode($body, true);
$explData = explode("\n",$resp);
$buttons = ["Current", "Next", "Prev", "First"];
$links = $explData[15];
$pageLinks = explode(",", $links);
$pages = array_fill(0, 4, null); //the page URL links
$rels = array_fill(0, 4, null); //references (i.e "current", "next", "prev", "last")
$pageNums = array_fill(0, 4, null); //amount of pages
$i = 0;
foreach($pageLinks as $p) {
$pages[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], "<", ">");
$rels[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], 'rel="', '"');
$pageNums[$i] = AppHelper::instance()->get_string_between($pageLinks[$i], "?page=", "&");
$i++;
}
if (array_key_exists("errors", $data)) {
$validReturn = false;
echo "Invalid page found.</br>";
}
else {
foreach ($data as $d) {
if((array_key_exists("id", $d)) && (self::hasBBDirect($d["id"]))) {
echo "Matching folder FOUND in course " . $d["id"] . "</br>";
} else {
echo "No matching folder found in course " . $d["id"] . "<br>";
}
}
}
curl_close($curl);
echo "<h4>Going to view Folder</h4>"; //THE LAST line reached
return view('folder')
->with("data", $data)
->with("rels", $rels)
->with("pages", $pages)
->with("pageNums", $pageNums);
echo "<h4>Didn't go?</h4>";
}
And my view, "folder.blade.php":
<html>
<head>
<title>Placeholder</title>
</head>
<body>
<h1>Hi</h1>
</body>
</html>
Why do I never get to the view? The code gets to the "return" call, and stops. What's wrong?
As you have not replied and I'm about to go to bed, I'll guess at your problem.
You call controller function findFolderPageNum...
public function findFolderPageNum()
{
// do some stuff
// do more stuff
$something = $this->findBBDirect($stuff);
// bit more stuff
return;
}
public function findBBDirect($things)
{
// yada yada
echo "<h4>Going to view Folder</h4>"; //THE LAST line reached
return view('folder')
->with("data", $data)
->with("rels", $rels)
->with("pages", $pages)
->with("pageNums", $pageNums);
echo "<h4>Didn't go?</h4>";
}
1st observation <h4>Didn't go?</h4> will never happen because this is dead code as it appears AFTER the return statement.
2nd observation You call findBBDirect. It returns a view, but you don't do anything with it. and simply return from the controller.
You need to either
return $this->findBBDirect($stuff);
or save what it returns and then return this. for example, I captured the return in $something.
then you can do other things then
return $something;
Please or to participate in this conversation.