Jump to content

So I am a total php noob so fell free to point any major issues out. Anyways I have a web server running the latest versions of apache and php on ubuntu 16.04.

 

So here is the issue. I need to use composer. I have installed composer. Now I need to use the autoload function. In theory to do this all you do is require autoload.php which is located in /root/vendor. So I try

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

I get a warning followed by a fatal error with basically the same message 

Quote

require(/var/www/html/sandbox5678/StreamIt/root/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/sandbox5678/StreamIt/index.php on line 6

 

 

The key part of the above is No such file or directory in /var/www/HTML/sandbox5678/StreamIt/index.php on line 6 

This tells me that php is looking only in the folder where the file is running my question is how do I make it look somewhere else???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Link to post
Share on other sites

So, your include is actually something more like

 /var/www/html/sandbox5678/StreamIt/var/www/html/sandbox5678/StreamIt/root/vendor/autoload.php

 

if that makes sense. When you include in PHP, it's a relative path, relative to where the PHP file you're including to is located. So if your file is in the streamit directory and you want to include autoload.php you would use include('root/vendor/autoload.php');

 

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to post
Share on other sites

15 hours ago, Hazy125 said:

So, your include is actually something more like

 /var/www/html/sandbox5678/StreamIt/var/www/html/sandbox5678/StreamIt/root/vendor/autoload.php

 

if that makes sense. When you include in PHP, it's a relative path, relative to where the PHP file you're including to is located. So if your file is in the streamit directory and you want to include autoload.php you would use include('root/vendor/autoload.php');

 

Ok that worked a bit but now I get new errors

 


Warning: include(/root/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/sandbox5678/StreamIt/index.php on line 6

Warning: include(): Failed opening '/root/vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/sandbox5678/StreamIt/index.php on line 6

 

Link to post
Share on other sites

33 minutes ago, TheComputerdude said:

Ok that worked a bit but now I get new errors

 



Warning: include(/root/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/sandbox5678/StreamIt/index.php on line 6

Warning: include(): Failed opening '/root/vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/sandbox5678/StreamIt/index.php on line 6

 

the user php is running as needs permission to read the file.

 

you can use ../ to move one Dir above.

 

If you were in /var/www/ ../ would out you in var and ../../ would put you in / 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

On 13/08/2017 at 9:31 PM, TheComputerdude said:

Ok that worked a bit but now I get new errors

 



Warning: include(/root/vendor/autoload.php): failed to open stream: Permission denied in /var/www/html/sandbox5678/StreamIt/index.php on line 6

Warning: include(): Failed opening '/root/vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/sandbox5678/StreamIt/index.php on line 6

 

Your webserver does not have permission to read the file at /root/vendor/autoload.php

 

/root/ is the home directory of the "root" user.

AMD Ryzen 7800 X3D, MSI B650 Project Zero, Antec C5, Gigabyte RTX 4080 Super Aero

 

Nikon D500 | Nikon 300mm f/4 PF  | Nikon 200-500 f/5.6 | Nikon 50mm f/1.8 | Tamron 70-210 f/4 VCII | Sigma 10-20 f/3.5 | Nikon 17-55 f/2.8 | Tamron 90mm F2.8 SP Di VC USD Macro | Neewer 750II

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×