[TYPO3] Loading TYPO3 outside TYPO3

Andreas Balzer eMail at andreas-balzer.de
Sun Mar 19 15:16:48 CET 2006


Andreas Balzer schrieb:
> derjoerg schrieb:
>> Andreas Balzer schrieb:
>>> derjoerg schrieb:
>>>> Johannes Reichardt schrieb:
>>>>> Hi there,
>>>>>
>>>>> i have some neat functions in my own extensions that use the dbal 
>>>>> and other Typo3 functions. But i also have a script outside the 
>>>>> scope of typo3 (for a cronjob) that uses these functions.
>>>>>
>>>>> The point is, that i am confused how i can properly "load" typo3 
>>>>> and its classes so i can access them from an "outside" script. 
>>>>> Would be glad if someone has some hints. Unfortunatly i have not 
>>>>> much knowledge about handling classes in general and moreover 
>>>>> handling classes with typo3 ;)
>>>>>
>>>>> - Johannes
>>>>
>>>> Look at 
>>>> http://typo3.org/documentation/document-library/core-documentation/doc_core_inside/current/view/3/5/ 
>>>>
>>>>
>>>> and search for "CLI mode".
>>>>
>>>> Joerg Schoppet
>>>
>>> Hi!
>>> I tried it, but it doesn't really work :-/
>>> Here is my try.. Can you help me and say me, what i have done wrong? 
>>> (i know, it's very unsecure, but it's just my first try..)
>>>
>>
>> Try to start it over the command-prompt "php -f 
>> c:\Programme\typo3\htdocs\typo3wamp\winremote\script.php" and look at 
>> the output.
>>
>> Sometimes this helps a lot.
>>
>> e.g.:
>> - wrong paths
>> - _cli_winremote is not allowed to be a admin
>> - look at the log in the be. Perhaps the user has not the necessary 
>> rights to insert a record
>> - look in the table-content (phpmyadmin), if the record is created
>>
>> Regards
>>
>> Joerg
>>
> Hi! I looked through.. Well, you're right, the access settings were not 
> correct and also the paths..
> I changed it to:
> <?php
> /*This file should create a BE cli connection to the user _cli_winremote 
> with pwd winremote
>  This file is in
> c:\Programme\typo3\htdocs\typo3wamp\winremote\
> Typo3 BE is in
> c:\Programme\typo3\htdocs\typo3wamp\typo3\
> 
> As soon as a connection is set up, this file should simply create a new 
> page.
> The only id that's already used is 1, so we create the pid 2.
> 
> Problem: It does not work, no output, nothing..
> 
> (Script is opened via Webbrowser..)
> */
> 
> // *****************************************
> // Standard initialization of a CLI module:
> // *****************************************
> // Defining circumstances for CLI mode:
> define('TYPO3_cliMode', TRUE);
> 
> // Defining PATH_thisScript here: Must be the ABSOLUTE path of this 
> script in the right context:
> // This will work as long as the script is called by it's absolute path!
> //define(PATH_thisScript, $_ENV['_'] ? $_ENV['_'] : $_SERVER['_']);
> define(PATH_thisScript, 
> 'c:/Programme/typo3/htdocs/typo3wamp/typo3/init.php');
> 
> // Include configuration file:
> define('TYPO3_MOD_PATH', 'c:/Programme/typo3/htdocs/typo3wamp/winremote/');
> $BACK_PATH = 'c:/Programme/typo3/htdocs/typo3wamp/typo3/';
> $MCONF['name'] = '_CLI_winremote';
> 
> // Include init file:
> require($BACK_PATH.'init.php');
> 
> 
> 
> 
> require_once (PATH_t3lib."class.t3lib_tcemain.php");
> $tce = t3lib_div::makeInstance('t3lib_TCEmain');
> $tce->stripslashes_values = 0;
> 
> $inhalte['pages']['2'] = array(
> 
>     "title" => "The page title",
> 
>     "subtitle" => "Other title stuff",
> 
>     "pid" => "1"
> 
> );
> 
> $tce->start($data,$inhalte);
> 
> $tce->process_datamap();
> 
> ?>
> 
> 
> 
> Well, nothing happens.. I looked in the Typo3 log. If i change the cli 
> user to admin (which is not allowed), i get an error. If i try to log in 
> as a different user, i get an error too.. ..so actually the script can 
> find typo3. Then i looked into phpmyadmin, because typo3 doesn't show 
> anything.. > There is no new entry.. So actually nothing happens :-/ By 
> the way, the command prompt outputs 4 empty lines and then asks me for 
> an other command.. (but it seems to work, because my firewall asked me, 
> if i want to allow cli to act as a server or allow internet connection.. 
> (i use zonealarm)..
> 
> So, what do i have to do?
> 
> Please help me
> Andreas
By the way, if i change PATH_thisScript to 
c:/Programme/typo3/htdocs/typo3wamp/winremote/index.php (where my script 
is) i get the following error. So i ask myself, whether this should be 
the path to typo3 or my script..

Error in init.php: Path to TYPO3 main dir could not be resolved correctly.

This happens if the last 6 characters of this path, , (\$temp_path) is 
NOT "typo3/" for some reason.
You may have a strange server configuration. Or maybe you didn't set 
constant TYPO3_MOD_PATH in your module?
If you expect any help from anybody on this issue, you should save this 
page as an html document and send it along with your request for help!
--------------------------------------------------------------------------------

Array
(
     [TYPO3_OS] => WIN
     [PATH_thisScript] => 
c:/Programme/typo3/htdocs/typo3wamp/winremote/index.php
     [php_sapi_name()] => apache2handler
     [TYPO3_MOD_PATH] => c:/Programme/typo3/htdocs/typo3wamp/winremote/
     [PATH_TRANSLATED] =>
     [SCRIPT_FILENAME] => 
C:/Programme/typo3/htdocs/typo3wamp/winremote/index.php




More information about the TYPO3-english mailing list