0

I am trying to use vendor/autoload but it keep giving me this error:

Illuminate\View\Engines\PhpEngine::main(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR')

I check that it is because of the path problem but nothing works: Some said that it should be something like this based on my autoload.php:

require_once __DIR__ . '/vendor/autoload.php'; //but doesn't work

And some said that it is already there so there is no need for require autoload and all I have to do is composer dump-autoload but still nothing. Based on this link, Laravel 5 how to include autoload.php

this is my autoload file: (located at \project\vendor)

<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit63603d79616e7bbd4553d0e6de44e738::getLoader();

Can someone help me with this problem? Thanks in advance

Dkna
  • 409
  • 3
  • 15
  • 37
  • 1
    Where is the vendor directory in relation to the script which is including the autoloader? Is it `/project/index.php` which contains the `require_once 'vendor/autoload.php';`? – Lawrence Cherone Dec 11 '17 at 01:55
  • What are you actually doing that requires you to include `vendor/autoload.php`? And have you actually run a `composer install`? – fubar Dec 11 '17 at 02:10
  • @LawrenceCherone the directory is at C:\xampp\htdocs\project\vendor where it contain the autoload file. Or are you saying there is another autoload file? – Dkna Dec 11 '17 at 02:23
  • @fubar I tried doing composer install already and it said they are all up to date and I am doing the autoload so that it can generate a table when i convert it into mircrosoft words at my blade – Dkna Dec 11 '17 at 02:24
  • Did you read the answer at that link in your post? Why do you want to manually include the autoload file in your Laravel project? – common sense Dec 12 '17 at 13:34
  • @konafets I want to include autoload because I wanted to use ms words but it ok I used javascript to do it – Dkna Dec 13 '17 at 00:45
  • Out of curiosity. Do you mean Microsoft Words? How do you want to *use* it with composer? Can you describe your main task you try to accomplish? – common sense Dec 13 '17 at 09:22
  • I actually wanted to create a table in Mircrosoft words but my previous situation was because the table lines won't appear so I tried using PHPWord package but there is this part where they say require autoload.php so when I tried doing that it didn't work and kept giving me an error. But I solved it by using another javascript called FileSaver and wordexport.js. Thanks for trying to help anyways :) @Konafets – Dkna Dec 13 '17 at 09:26
  • Can you link here to the place where they mention including the autoloader? – common sense Dec 13 '17 at 09:48
  • It was this link, https://www.youtube.com/watch?v=A-TusPXnsL4 at 3.40 for the autoload, but the original is from here, https://github.com/PHPOffice/PHPWord @Konafets – Dkna Dec 13 '17 at 09:57
  • OK. The guy in the video creates an application from scratch and therefore he includes the `autoload.php`. In Laravel this is already done for you. Just create a new object as shown in the README of the package. – common sense Dec 13 '17 at 10:12
  • Ohhh I see thank you so much for your explanation now it make sense why it doesn't work for me @Konafets – Dkna Dec 14 '17 at 01:04

1 Answers1

-1

If you get the error also when you run

composer install

Just run this command first

composer dump-autoload

This command will clean up all compiled files and their paths.

Ngaiza
  • 221
  • 2
  • 4