14

I just installed laracast/flash and updated nesbot/carbon via composer. The cmd went nuts while downloading carbon. Cmd interface displayed scattered words and boxes all over the interface for a while and the download was completed. Did php artisan serve at localhost:8000 and I've got the following errors.

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\NC World\ProjectName\server.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0

Community
  • 1
  • 1
Angnima Sherpa
  • 224
  • 1
  • 2
  • 11
  • Try reinstalling the package to see if it fixes something. Otherwise i'll recommend installing the package one by one and see if you see any breaking changes between. I'm pretty sure that Laravel comes with Carbon by default. – Mauran Muthiah Mar 30 '18 at 13:01
  • I did try reinstalling/removing packages. But had no luck. Idk what's going on here. – Angnima Sherpa Mar 30 '18 at 13:03
  • Just give permission to the folder,hope it will work.. – Nithin John Mar 30 '18 at 13:13

9 Answers9

50

This error happens because the server.php file is missing. May be it is deleted or removed from your project directory. I have already faced this problem. Just add the server.php file at root of your project. You can add this file from any other laravel project directory or just create a file named server.php at root directory of your laravel project and paste the following code:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}

require_once __DIR__.'/public/index.php';

This process works for me.

rroy
  • 753
  • 7
  • 10
40

Try to disable your anti-virus, this happens to me, it seems avast deletes my server.php.

So I added it to the exception

Ikong
  • 2,540
  • 4
  • 38
  • 58
  • Yes. that was the problem with me too. But only the server.php files in 5.6 laravel project is being deleted. Whereas other versions of laravel is left untouched. – Angnima Sherpa Apr 06 '18 at 06:46
  • I tried a safer variant of this answer. I disabled Avast's behavior shield indefinitely then recreated my Laravel project with `laravel new project_name -f`. Maybe just disabling the behavior shield before creating a project can work. – Joachim Rives Jan 09 '20 at 07:11
  • had similar issue with laravel 7+XAMPP so I disabled the Avasta aniti and replace the server.php file. – pTi May 24 '20 at 10:09
  • may I know how to create a exception? – Mathew Magante Jun 03 '20 at 12:32
24

Type in the command line:

php -S localhost:8000 -t public

because port is not public

Beppe C
  • 11,256
  • 2
  • 19
  • 41
Laid said
  • 241
  • 2
  • 2
1

go to main directory and create new server.php file even you can also copy paste from another created project

same happens to me and i just remove antivirus from my system and just create new file of server

  • Hi! Welcome to Stackoverflow! Please have a look at [How To Answer](https://stackoverflow.com/help/how-to-answer). Trivial answers must go in comments section only – Ankur Aggarwal Jan 02 '19 at 03:37
0

You can also go in your antivurus params and restore server.php + add an exception it worked fine for me without recreate a project.

Ari
  • 1
  • 1
0

same thing happens with me server.php file is deleted by antivirus. so, I just add server.php file inside vendors\laravel\framework\src\illuminate\foundation\resources it works for me

Ramesh Nepali
  • 101
  • 1
  • 5
0

I am using Avast Free Antivirus, and it has detected server.php as a virus. Please restore server.php from the quarantine of your antivirus software.

Rahmad Al Habib
  • 300
  • 4
  • 7
-1

same problem happen to me: just delete the project and uninstall the avast antivirus and re create the project

-1

This same thing happens with me just create new laravel project and copy server.php from the new project and paste it to your project

Rabby
  • 322
  • 4
  • 15