Reputation: 33
I have searched the forums already, but none of the solutions have seemed to help me.
Basically I have just installed and created a package using composer. I need to autoload the classes, sounds pretty standard.
I followed all the instructions, and have added this line of code to my script:
require_once 'vendor/autoload.php';
The vendor folder is located in the root folder of my server, here:
/root/vendor/autoload.php
So, I added
:/root
To my PHP ini file so that PHP searches in the root folder when looking for includes. I thought that should work but it's not :(
My PHP ini file now looks like this:
.:/usr/lib/php:/usr/local/lib/php:/root
The error message I am getting is this:
[14-Jul-2014 16:46:29 Europe/London] PHP Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/root') in /home/owned/public_html/trythis/ow_plugins/oftokbox/bol/service.php on line 38
Any ideas?
Upvotes: 2
Views: 1613
Reputation: 70863
You implicitly state you are using Composer for a project. By doing so you must have a composer.json
file somewhere. And Composer will create a vendor folder directly in the folder containing this file.
So if you also have a file index.php
in the folder containing the composer.json
, to include the autoloader you would use require 'vendor/autoload.php';
.
If however you follow some security guidelines and have a dedicated folder containing public files, then the file would for example be called public/index.php
, and for this file to reach the autoloader, the relative path would be require '../vendor/autoload.php';
.
Composer cannot give a one-instructions-fits-all direction because it depends on which folder structure you have. But including the composer autoloader is just the same task as including any other file with a relative path.
Upvotes: 1