Summer Sale! All accounts are 50% off this week.

SarahS's avatar
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?

0 likes
4 replies
SarahS's avatar
Level 12

It's not Laravel. PHP is 7.3. Thanks.

MichalOravec's avatar
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');
SarahS's avatar
Level 12

Good question. I have no idea why it's there and no idea why I couldn't see it!

Thanks, it all works fine now.

Please or to participate in this conversation.