[TYPO3-english] Upgrade to 4.5 LTS: external script error makeInstance('t3lib_DB')

Markus Klein klein.t3 at mfc-linz.at
Mon Jul 15 12:29:38 CEST 2013


Hi!

I suggest to convert the scripts to EID scripts.
This will take care of the basic bootstrap setup and you've the DB available.

Ext_localconf.php:
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');

$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['myextkeyword'] = 'EXT:' . $_EXTKEY . '/thescript.php';

?>

Thescript.php:
<?php

// Exit, if script is called directly (must be included via eID in index_ts.php)
if (!defined('TYPO3_MODE') || TYPO3_MODE !== 'FE') {
	die('Could not access this script directly!');
}

tslib_eidtools::connectDB();
// now we have the db

?>


Take a look at all the methods of tslib_eidtools.
(Since TYPO3 CMS 6.0 this class is named TYPO3\CMS\Frontend\Utility\EidUtility)

Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member

> -----Original Message-----
> From: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-
> bounces at lists.typo3.org] On Behalf Of Gregory Loichot
> Sent: Monday, July 15, 2013 12:07 PM
> To: typo3-english at lists.typo3.org
> Subject: [TYPO3-english] Upgrade to 4.5 LTS: external script error
> makeInstance('t3lib_DB')
> 
> Hello,
> 
> I'm upgrading sites from 4.2 to 4.5. Somes sites use PHP scripts to import data
> into TYPO3 DB. So I need to create an instance of t3lib_DB to use TYPO3 DB
> functions.
> 
> I have something like:
> 
> define('PATH_project', '/var/www/myproject/'); // dev version
> 
> define('PATH_t3lib', PATH_project.'t3lib/'); define('PATH_typo3conf',
> PATH_project.'typo3conf/');
> 
> //Include of the files
> require_once(PATH_t3lib.'class.t3lib_div.php');
> require_once(PATH_t3lib.'class.t3lib_extmgm.php');
> require_once(PATH_t3lib.'config_default.php');
> require_once(PATH_typo3conf.'localconf.php');
> require_once(PATH_t3lib.'class.t3lib_db.php');
> 
> //Instance of t3lib_db
> $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
> 
> But that include fails: require_once(PATH_t3lib.'config_default.php');
> 
> Error : PHP Fatal error:  require(): Failed opening required
> 'PATH_typo3sysext/cms/ext_autoload.php'
> (include_path='.:/usr/share/php:/usr/share/pear') in
> /var/www/myproject/typo3_src/t3lib/core_autoload.php on line 214
> 
> Any ideas? Is there a better way including t3lib_DB?
> Thanks
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list