failed to open stream error message while trying to include phpseclib
Asked Answered
S

2

2

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.

Sherri answered 23/7, 2012 at 19:54 Comment(0)
S
2

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.

Sherri answered 24/7, 2012 at 18:9 Comment(0)
S
0

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');
          ?> 
Superstratum answered 23/7, 2012 at 20:1 Comment(3)
phpseclib.sourceforge.net has the install instructions... you'll see the exact same code i have on this page...Sherri
Alright. Just try roughly set the absolute path. For example create folder "phpseclib" in your folder "test" and do <?php set_include_path("C:var/www/test/phpseclib") ; ?> dont forget to put all needed files inside it.Superstratum
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 now the page works.Sherri

© 2022 - 2024 — McMap. All rights reserved.