[TYPO3-mvc] Using external libraries within Extbase Extension

Sebastian Schreiber me at schreibersebastian.de
Wed Aug 3 17:03:15 CEST 2011


Hi Hauke,
have a look at the code from the extension zend_framework.
http://typo3.org/extensions/repository/view/zend_framework/current/

The author sets the include_path in the ext_localconf.php.
Check out the way he did it and you should be fine.
I guess that your path definition is incorrect.
Otherwise it would not be necessary to use the autoloader functionality 
of typo3.

Good luck

Am 03.08.2011 16:12, schrieb Hauke Stange:
> On Wed, 2011-08-03 at 15:31 +0200, Hauke Stange wrote:
>> On Wed, 2011-08-03 at 13:34 +0200, Hauke Stange wrote:
>>> Hi there.
>>>
>>> I just want to know if there is a preferred way for using external
>>> libraries within an extension. In my case I have to use some existing
>>> code which uses some of the PEAR libraries.
>>>
>>> Is there a way for putting the files in a certain directory similar to
>>> the /Service/ or /Utility/ directories?
>> Ok, my first guess (dirty hack) was wrong. I copied the needed Libraries
>> to 'EXT:/Resources/Libraries/PEAR/' and included the following lines of
>> code where needed...
>>
>> $extensionPath = t3lib_extMgm::extPath('gpqg');
>> $pearPath      = $extensionPath . 'Resources/Libraries/PEAR/';
>> if (! set_include_path($pearPath . PATH_SEPARATOR . get_include_path()))
>> {
>>      throw new Exception("What the heck!!!");
>> }
>> require_once 'Net/SFTP.php';
>> $sftp = new Net_SFTP(Sftp::host, Sftp::port);
>>
>> The Autoloader(s) from Typo3 / Extbase of course failed to load the
>> 'Net_SFTP' class.
> Ok, still searching for a solution I just tried this
> "createAutoloadRegistryForExtension"-stuff from Extbase...
>
> $extensionPath = t3lib_extMgm::extPath('gpqg');
> $pearPath      = $extensionPath . 'Resources/Libraries/PEAR/';
>
> $classMap= array(
>      'net_sftp' =>  "'{$pearPath}Net/SFTP.php'"
> );
>
> Tx_Extbase_Utility_Extension::createAutoloadRegistryForExtension(
> 'gpqg', $extensionPath, $classMap);
>
> $sftp = new Net_SFTP(Sftp::host, Sftp::port);
>
> The corresponding ext_autoload.php file looks like this:
>
> $extensionClassesPath = t3lib_extMgm::extPath('gpqg') . 'Classes/';
> return array(
> 	// All my Extbase classes come here first...
> 	'net_sftp' =>  '/path/to/Resources/Libraries/PEAR/Net/SFTP.php',
> );
>
>
> Still not happy,
> Hauke
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 217 / 5269 / 4675



More information about the TYPO3-project-typo3v4mvc mailing list