Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'TeamSpeak3_Helper_String' not found #137

Closed
RikoDEV opened this issue Jan 25, 2020 · 25 comments
Closed

Class 'TeamSpeak3_Helper_String' not found #137

RikoDEV opened this issue Jan 25, 2020 · 25 comments
Assignees
Labels
compatibility Issue with (unsupported) version, tool, or anything outside scope of framework

Comments

@RikoDEV
Copy link

RikoDEV commented Jan 25, 2020

When I want to connect to the Team Speak server I get the error:

Symfony\Component\Debug\Exception\FatalThrowableError  : Class 'TeamSpeak3_Helper_String' not found

at /var/www/domain.com/vendor/planetteamspeak/ts3-php-framework/libraries/TeamSpeak3/Helper/Uri.php:218
    214|    * @return TeamSpeak3_Helper_String
    215|    */
    216|   public function getScheme($default = null)
    217|   {
  > 218|     return ($this->hasScheme()) ? new TeamSpeak3_Helper_String($this->scheme) : $default;
    219|   }
    220|
    221|   /**
    222|    * Returns TRUE if the username is valid.

PHP 7.4.2
Laravel 6.8.0

My code:

use TeamSpeak3;
use TeamSpeak3_Exception;

try {

    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://x.x.x.x:10011/?server_port=9987");

    $name = $ts3_VirtualServer->clientGetById(47);
    print_r($name->getInfo(TRUE));

} catch(TeamSpeak3_Exception $e) {

    return "Error " . $e->getCode() . ": " . $e->getMessage();

}
@svenpaulsen
Copy link
Contributor

Seems to be an autoloading issue. I'll take a look at this as soon as I get the chance, but for now, I'd suggest including the TeamSpeak3/Helper/String.php file (and others you might need) manually.

@svenpaulsen svenpaulsen self-assigned this Feb 15, 2020
@svenpaulsen svenpaulsen added the compatibility Issue with (unsupported) version, tool, or anything outside scope of framework label Feb 15, 2020
@Sebbo94BY
Copy link
Collaborator

Sebbo94BY commented Apr 19, 2020

I have the same problem.

Seems like as it's related to PHP 7.4, because with PHP 7.3 I don't had this issue.

I've also tested older versions of this library, but downgrading didn't fix this issue.

Is there any reason for this difference here?

"autoload": {
"files": ["libraries/TeamSpeak3/TeamSpeak3.php"]
},
"autoload-dev": {
"psr-0": {
"": "libraries/"
},

@jskramer909
Copy link

Had the same problems upgrading to PHP7.4.

Found out that it is related to this deprecation:
https://wiki.php.net/rfc/deprecate_curly_braces_array_access.

Fixing the Helper/String.php and also the Adapter/Host.php

It is working fine for me again.

@ronindesign
Copy link
Collaborator

Master has a merged PR regarding replacing curly braces with brackets. Maybe it is related and would resolve this? #142

@Sebbo94BY
Copy link
Collaborator

I've checked out the current master (dev-master b14b8c8), but I'm still getting the same error message as reported in the first comment.

So no, this does not resolve it.

@Sebbo94BY
Copy link
Collaborator

I've created a PR #145. As soon as this is merged, I'll test this issue again with the current code from the develop branch.

@Sebbo94BY
Copy link
Collaborator

Any news regarding this issue?

@ronindesign
Copy link
Collaborator

I commented on your PR, was waiting for you to resolve the Travis CI ssh issue before merging into dev.

@Sebbo94BY
Copy link
Collaborator

I've unfortunately not found any solution to install the PHP extension ssh2. All what I've found with Google didn't work. :(

@ronindesign
Copy link
Collaborator

It might be a bit overkill, but maybe we could compile the extension from source for each instance...?

@Sebbo94BY Sebbo94BY mentioned this issue May 17, 2020
Merged
@Sebbo94BY
Copy link
Collaborator

Some changes and fixes have been merged into dev. Let's test and fix this issue on this branch.

@Sebbo94BY
Copy link
Collaborator

Ok, just tested the dev branch. It fixed the initial issue. I just got the error Class 'TeamSpeak3' not found after "updating" the library, but this was easily fixed by reimporting the classes with the new namespace.

Old:
use TeamSpeak3;

New:
use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;

After changing this, I get now the following error message:

   Symfony\Component\Debug\Exception\FatalThrowableError  : Call to undefined method PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3::getAdapterName()

  at /home/vagrant/vendor/planetteamspeak/ts3-php-framework/src/TeamSpeak3.php:337
    333|         self::init();
    334| 
    335|         $uri = new Uri($uri);
    336| 
  > 337|         $adapter = self::getAdapterName($uri->getScheme());
    338|         $options = ["host" => $uri->getHost(), "port" => $uri->getPort(), "timeout" => (int) $uri->getQueryVar("timeout", 10), "blocking" => (int) $uri->getQueryVar("blocking", 1), "tls" => (int) $uri->getQueryVar("tls", 0), "ssh" => (int) $uri->getQueryVar("ssh", 0)];
    339| 
    340|         self::loadClass($adapter);
    341| 

@Sebbo94BY
Copy link
Collaborator

Sebbo94BY commented Jun 2, 2020

I've fixed that issue, but there is now a different issue.

   ErrorException  : scandir(TeamSpeak3/Adapter/): failed to open dir: No such file or directory

  at /home/vagrant/vendor/planetteamspeak/ts3-php-framework/src/TeamSpeak3.php:416
    412| 
    413|   protected static function getAdapterName($name, $namespace = "TeamSpeak3_Adapter_")
    414|              {
    415|                              $path = self::getFilePath($namespace);
  > 416|                                      $scan = scandir($path);
        }
    417| 
    418|                                      foreach($scan as $node)
    419|                                                      {
    420|                                                                          $file = StringHelper::factory($node)->toLower();

Running from one issue to another one. :(

Could someone of you take a look at this please? @ronindesign @svenpaulsen

composer require planetteamspeak/ts3-php-framework:dev-dev

@Sebbo94BY
Copy link
Collaborator

@ronindesign @svenpaulsen any updates? :'(

@ronindesign
Copy link
Collaborator

Sorry for the lack of follow up on this! Hmm, at first glance, this seems like it might be a namespace / ps4 related problem. I know there's another issue related to namespacing / autoloading that Sven responded to, this might be related... I'll try to troubleshoot locally and follow up on this.

@Sebbo94BY
Copy link
Collaborator

This would be great, because I'm currently unable to manage any TeamSpeak 3 server since every API request is throwing this error. When do you expect a fix, which I or we can test?

@Sebbo94BY
Copy link
Collaborator

Any news?

@Sebbo94BY
Copy link
Collaborator

Any updates?

@ronindesign
Copy link
Collaborator

@Sebi94nbg Apologies this has been blocking you. I've not had much time to work on this recently.

Looking back at the error, two thoughts I have:

  1. Does this directory actually exist?
    /home/vagrant/vendor/planetteamspeak/ts3-php-framework/src/TeamSpeak3/Adapter/

  2. Is the scandir($path) relative? I.e. if you're running framework from something like /home/vagrant, it might be trying to find /home/vagrant/TeamSpeak3/Adapter/ and erroring out?

Though, I would think autoloader would manage this and scandir() call would be relative to TeamSpeak3.php's location, so I'm back to square one... not sure why it's not finding the relative directory path.

Maybe you can troubleshoot by doing getcwd() something like:

 protected static function getAdapterName($name, $namespace = "TeamSpeak3_Adapter_")
              {
                             $path = self::getFilePath($namespace);
                                     var_dump(getcwd()); // or even die(getcwd());
                                     $scan = scandir($path);
                                     ...

Just to confirm the relative path? Apologies, again I don't have much time to test if composer / autoloading issue.

@Katalam
Copy link

Katalam commented May 1, 2021

I still get the same issue as described in the very first comment. Is there any fix for this?

Class "TeamSpeak3_Node_Server" not found
C:\Users\admin\Documents\UCP\vendor\planetteamspeak\ts3-php-framework\libraries\TeamSpeak3\Node\Host.php:286

It works locally on mac os but windows.

@jballzz
Copy link

jballzz commented May 12, 2021

I am also having this issue, mine started causing an error when i updated composer to version 2 ?

@Domenikus
Copy link

Same for me

@B4T3S
Copy link

B4T3S commented Jul 9, 2021

I'll just chime in and share how I fixed the "TeamSpeak3_Node_Server" issue (at least locally, some other issues might still arise with these fixes)
I inserted a simple require at the top of "Adapter\ServerQuery.php"
require('S:\wwwroot\website\vendor\planetteamspeak\ts3-php-framework\libraries\TeamSpeak3\Node\Host.php');
(Your path may vary)
I also inserted a require into "Node\Host.php"
require('S:\wwwroot\website\vendor\planetteamspeak\ts3-php-framework\libraries\TeamSpeak3\Node\Server.php');
And at last I changed $id1 into $id1 = 0 in lines 2021 and 2036 within Node\Server.php

I hope I can help someone with this ^^

@dannyot
Copy link

dannyot commented Jul 11, 2021

Hey there? a new Solution?

I did a workarround just implement it without composer. So download and Copy. This works fine. However, not the best solution.

@ronindesign
Copy link
Collaborator

Closing this for now as I believe it is resolved in dev branch. Please target that in composer unless you experience issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Issue with (unsupported) version, tool, or anything outside scope of framework
Projects
None yet
Development

No branches or pull requests

10 participants