1

I'm working on Laravel 5.2 framework and run first time project

When i run root link display error:

Warning: require(/home/ubuntu/workspace/../bootstrap/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0028 236248 1. {main}() /home/ubuntu/workspace/index.php:0 Fatal error: require(): Failed opening required '/home/ubuntu/workspace/../bootstrap/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0028 236248 1. {main}() /home/ubuntu/workspace/index.php:0

Before i call composer install

Its my application/.htpaccess:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)/$ /$1 [L,R=301]

     # Handle Front Controller...
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^ index.php [L]

    # Handle Authorization Header
     RewriteCond %{HTTP:Authorization} .
     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

     RewriteRule ^(.*)$ public/$1 [L]

</IfModule>

routes.php

Route::get('/', function () {
    return view('welcome');
});

application/index.php

require __DIR__.'/../bootstrap/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

EDIT:

I replaced in index.php to

require __DIR__.'/../vendor/autoload.php';

But display error:

Warning: require(/home/ubuntu/workspace/../vendor/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0004 233376 1. {main}() /home/ubuntu/workspace/index.php:0 Fatal error: require(): Failed opening required '/home/ubuntu/workspace/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0004 233376 1. {main}() /home/ubuntu/workspace/index.php:0

I have folder vendor in root directory. How me solve this issue? Thank you.

5
  • Run this commands in terminal: php artisan clear-compiled , composer install , composer update , composer dump-autoload. Commented May 11, 2016 at 9:06
  • The autoload file is located in the vendor folder. Try require __DIR__.'/../vendor/autoload.php'; instead. Commented May 11, 2016 at 9:07
  • i changed to DIR.'/../vendor/autoload.php'. Error: Failed opening required '/home/ubuntu/workspace/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') Commented May 11, 2016 at 9:21
  • What is your php version? I'm getting this error when I used PHP < 5.5.9 Commented May 11, 2016 at 10:10
  • you will probably find your solution by following the steps here : stackoverflow.com/questions/36577020/… Commented May 15, 2016 at 21:09

3 Answers 3

4

I had the same issue but bellow command over the composer sort out everything for me.

composer update --no-scripts

Sometimes when you run: composer install you got that error too, so the best option is first to run: composer install --no-scripts and then run composer install normally.

Sign up to request clarification or add additional context in comments.

Comments

2

__DIR__ is an absolute path to the directory of the script that you're running.

Get a terminal and cd to the directory where this script lives. From there, use ls together with paths such as up one directory (../) and the tab-based autocompletion to find the path that you need to use to locate the autoload.php from your index script.

If you get a result like this:

$ ls ../public/index.php
ls: cannot access ../public/index.php: No such file or directory

Then you know the file doesn't exist at the path specified.

I feel it's better to answer this question by telling you how to find it rather than guessing at where it should be.

2 Comments

thank you. I delete one /../. Load without this error, but now display Whoops, looks like something went wrong.
There is a troubleshooting checklist for this error here : stackoverflow.com/questions/36577020/…
1

I think it's the issue in your composer.json because i also had the same.

Please replace your whole "scripts" object in composer.json with this..

"scripts": {
        "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postInstall",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postUpdate",
        "php artisan optimize"
    ]
},

Now try to run composer install if not works then composer update.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.