I'm trying to include a path to autoload.php which is in
vendor/autoload.php
the file trying to access it is in
public/this-file.php
I set the path to require_once '../vendor/autoload.php';
but it just throws the error -
Warning: require_once(../vendor/autoload.php): failed to open stream: No such file or directory
Fatal error: require_once(): Failed opening required '../vendor/autoload.php' (include_path='.:/opt/php55/lib/php')
Does laravel offer a shortcode to access files in the vendor file
You don't need to require autoload.php
in a Laravel application, it's already being required. You can just add more package in your composer.json
file or do a composer require
in the command line, and it should work.
It is required in bootstrap/autoload.php
, if you don't believe me. ;)
/*
|--------------------------------------------------------------------- -----
| Register The Composer Auto Loader
|------------------------------------------------------------------------- -
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
If it doesn't for some reason, try composer dump-autoload
, which fixes a lot of "requiring" issues in Laravel, especially when working with seeders and that sort of thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With