user1545936
user1545936

Reputation: 41

failed to open stream error message while trying to include phpseclib

I'm trying to follow the instructions for installing phpseclib.

I unpackaged everything and created a new phpseclib folder into /usr/share/pear. So I have the following stucture:

/usr/share/pear/phpseclib/
                          Net
                          Crypt
                          File
                          Math

I determined the /usr/share/pear path by checking the get_include_path method.

And now i'm trying to create a page that uses the phpsec library.

Here's the php page I'm playing with:

<?php

set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');

The page bombs with an error message that says;

warning: include(Net/SSH2.php): failed to open stream: No such file or directory in /var/www/test/sshtest.php on line 4. Warning include(): failed opening 'Net/SSH2.php' for inclusion (include_path='.:/usr/share/pear:phpseclib') in /var/www/test/sshtest.php on line 4.

/var/www/test the webfolder where my page is. Any suggestions or pointers would be appreciated.

Upvotes: 2

Views: 9341

Answers (2)

user1545936
user1545936

Reputation: 41

I changed the code to read:

<?php 

set_include_path(get_include_path() . get_include_path().'/phpseclib');
include('Net/SSH2.php');
echo('if you are reading this, phpseclib has been included');

and that fixed the problem.

Upvotes: 2

sybear
sybear

Reputation: 7784

Did not you forget to place a slash / after setting the path?

So, should be like:

 <?php
          set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib/');
          include('Net/SSH2.php');
      ?> 

or

<?php
              set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib' . PATH_SEPARATOR);
              include('Net/SSH2.php');
          ?> 

Upvotes: 0

Related Questions