简体   繁体   中英

Call TYPO3 PHP function from outside TYPO3

I try to open an extbase view in a different window. For this I call the function \\typo3\\sysext\\extbase\\Classes\\Mvc\\Controller\\AbstractController->redirect() . But it fails, due to abstract class AbstractController implements ControllerInterface . It can not find ControllerInterface . It is in the folder, but the folder isn't included in the path get_include_path() . Is there any way to go arround this problem without changing the TYPO3 file?

On the surface this looks like a typical class loading issue, so I'll describe the pitfalls there in case someone comes searching for that type of error and finds this post.

If you installed TYPO3 via composer, make sure you load the composer autoload file from your external file. Composer paths do not appear in the PHP include paths, and you should never have to include any other file than the composer autoload file.

If you did not install via composer you will need to run your script in a TYPO3 context. Only then will class loading work.

That said: the fact that class loading is inactive indicates you are trying to use TYPO3 features completely outside TYPO3. It is no easy task to simply use TYPO3 classes outside of a TYPO3 context - especially not Extbase ones, and especially not controllers. There are so many dependencies on configuration, database and request handling. I would strongly discourage attempting to do this.

Even generating a link to a controller action involves calculating a request hash which in turn requires access to the TYPO3 configuration and database. So in all likelihood, what you are attempting is simply not possible - you need to do it from within a TYPO3 context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM