What is PHP and Laravel versions?
Aug 6, 2020
4
Level 12
PHP router error messages
I've been following the course PHP Practitioner and have been trying to implement it on my server. I had a few issues with the routing until I realised I needed a .htaccess file. Now the routing seems to work OK but I get these errors:
Warning: require(1): failed to open stream: No such file or directory in /var/sites/n/domain/public_html/app/controllers/PagesController.php on line 52
Warning: require(1): failed to open stream: No such file or directory in /var/sites/n/domain/public_html/app/controllers/PagesController.php on line 52
Fatal error: require(): Failed opening required '1' (include_path='.:/usr/local/php-5.6.37-flock/lib/php') in /var/sites/n/domain/public_html/app/controllers/PagesController.php on line 52
(I put domain in place of the real URL)
This is for the page Appointments. The PagesController is:
<?php
namespace App\Controllers;
class PagesController
{
/**
* Show the home page.
*/
public function home()
{
return view('index');
}
public function services()
{
require view('services');
}
public function appointments()
{
require view('appointments');
}
}
(this is a cut down version but line 52 is essentially:
require view('appointments');
What is causing the error and how can I fix it?
Level 75
@sarahs74 Why do you have in home return view('index'); and in other methods you use instead of return require ?
Change it to
return view('appointments');
Please or to participate in this conversation.