Warning: failed to open stream: No such file or di

2020-08-12 04:18发布

问题:

Environement

  • Windows 7
  • WAMP server
    • PHP 5.3.13
    • Apache 2.2.12
    • MySQL 5.5.24
  • Laravel 4.1

I installed laravel, trying to run the URL

http://localhost/laravel/public 

autoload.php

define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';

if (file_exists($compiled = __DIR__.'/compiled.php')){
    require $compiled;
}

Illuminate\Support\ClassLoader::register();

if (is_dir($workbench = __DIR__.'/../workbench')){
    Illuminate\Workbench\Starter::start($workbench);
}

I am facing the following errors:

Warning: require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\laravel\bootstrap\autoload.php on line 17

and

Fatal error: require() [function.require]: Failed opening required 'C:\wamp\www\laravel\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') in C:\wamp\www\laravel\bootstrap\autoload.php on line 17

回答1:

Go to the current Project folder

C:\wamp\www\laravelProjectFolder>

and type composer install in command prompt and press ENTER key.

composer install

Then the vendor directory will be downloaded in the current project of laravel. Now refresh the screen.



回答2:

Simply make your storage folder writable. This can be found in your app directory

In your terminal use this command

chmod +w <directory> or chmod a+w <directory>

Make sure you navigate to the directory containing the directory you want to make writable or you point to that path.



回答3:

go to your project folder via cmd. run the following command

composer update

it will install missing vendor folder and files in your project.

but in some cases it gives error like " Your configuration does not allow connection to bla bla bla.."

for that go to your composer.json file,

change "secure-http": true to "secure-http": false

but in some cases (as was in my case) you may not find such line in your file. for that do the following action:

change "config": { "preferred-install": "dist" }

to

"config": {
    "preferred-install": "dist",
    "secure-http": false
}

and run again composer update command.

hope this will solve problem of many persons. :)



回答4:

You are trying to include:

C:\wamp\www\laravel\bootstrap/../vendor/autoload.php

and the error gives

No such file or directory in 
         C:\wamp\www\laravel\bootstrap\autoload.php on line 17

so you need to check your directory layout. Is there a directory vendor in lavarel with a file autoload.php in it?

and you should either have / in your pathnames or \ but not mixed both.