1

I'm trying to write a simple extension which uses the Teamspeak3 PHP Framework (https://docs.planetteamspeak.com/ts3/php/framework/) just for showing the "Teamspeak3_Viewer_HTML" Element in the Frontend after giving the information like servername, port etc to the backend plugin.

The problem is: how to use the "external" php framework in my extension? I put the whole framework source in my extension folder, so i have typoconf/ext/myExtension/Libraries/Teamspeak3...

then I try to use it in my controller action

<?php
namespace Sc\Ts3view\Controller;
use \TeamSpeak3;

/**
 * Ts3viewController
 */
class Ts3viewController extends 
\TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
  /**
   * action show
   *
   * @return void
   */
  public function showAction()
  {                          
    $server = $this->settings['server'];

    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$server["ts_query_admin"].":".$server["ts_query_password"]."@".$server["tsip"].":".$server["ts_query_port"]."/?server_port=".$server["tsport"]."&nickname=".$server["ts_query_user_nick"]."");
    $resulthtml = $ts3_VirtualServer->getViewer(new TeamSpeak3_Viewer_Html("images/viewericons/", "images/countryflags/", "data:image"));

    $this->view->assign('resulthtml', $resulthtml);
  }    
}

But in Frontend I just got an error

"Oops, an error occurred! Code: 20170527153454d1abefa8"

although I have displayErrors on. Any ideas how to use this framework in my action?

Daniel
  • 6,916
  • 2
  • 36
  • 47
sxbxstxxn
  • 15
  • 6

1 Answers1

1

First if all, you either need to set your environment to Development or you have to set config.contentObjectExceptionHandler = 0 in your TypoScript template.

You get an exception, because the TYPO3 autoloader cannot find the classes. You need to add this to your composer autoload section:

"autoload": {
   "files": ["libraries/TeamSpeak3/TeamSpeak3.php"]
}

Or you can directly require the composer package in your root composer.json.

composer require planetteamspeak/ts3-php-framework
pgampe
  • 4,531
  • 1
  • 20
  • 31
  • Thx for your answer, I never used composer autoloader. I tried it now with "use \TeamSpeak3;" in my Controller and with your TypoScipt Code for Development Environment I got the exception "Failed to parse address "myteamspeakadress.net". So I think the class is working and THIS question is solved, I have to go on with the other question why it cannot connect to my teamspeak server. Thx a lot... – sxbxstxxn May 29 '17 at 09:02