Using TS3 PHP framework in TYPO3 Extension

205 views Asked by At

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?

1

There are 1 answers

1
pgampe On BEST ANSWER

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