Search code examples
phplaravelcomposer-phpautoload

LARAVEL: main(): Failed opening required 'vendor\autoload.php'


I followed this documentation and I keep getting that main(): Failed opening required 'vendor\autoload.php' error and I ran composer install but still get the same error. I'm using Laravel and I'm calling this from a Controller..

namespace App\Http\Controllers;

require 'vendor/autoload.php';
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Google\Cloud\Speech\SpeechClient;
use Google\Cloud\Speech\StorageClient;
use App\Model\FilesModel;
use Illuminate\Support\Facades\DB;

class FilesController extends Controller
{

    private $project_id;
    private $speech;
    private $options;
    private $storage;

    public function __construct()
    {
        $storage = new StorageClient([
            'keyFile' => json_decode(file_get_contents(public_path() . '/key.json'), true)
        ]);
    ....

How do I bypass this issue?


Solution

  • first of all no need to do that! because it's included in all pages...
    if you insist doing this I think the problem is the address of autoload file which have to be:

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