问题
I just came across this question How can I use a PHP script in typo3 v9? and for me more interesting is right now - should you even do it and what are the possible usecases?
The reason I am asking: I am currently useing standalone legacy PHP scripts on a site. Not happily, as I had always intended to migrate this to an extension or deprecate it, but as is often the case - the PHP scripts may long outlive PHP itself ;-)
Consider you have some functionality, which you want to integrate in your website (as content inside the existing theme) which uses no specific TYPO3 functionality. Are there reasonable usecases to do this as PHP script without creating an extension? This answer suggests that it was possible but has been discouraged.
What are the pros / cons? Is this not recommended? Why? ...
TYPO3 >= 9.
回答1:
Web Content Management is quite an old discipline and proably most requirements are known and years old. TYPO3 has adapted its architecture over the years to be more safe, more easy, more secure and to easily expand functionality. Thus, the idea of adding a plain PHP script instead of using the (omnipotent) API and extension library to include functionality means skipping the offered ideas of functionality, security and maintainability.
Nevertheless, adding functionality which is like a custom PHP script is easy, as the overhead to adapt a "spaghetti code php script" into the TYPO3 API is marginal (e.g. "put it in an extension", use PSR-0, with namespaces classes register the function with a ext_localconf.php
line) and would easily improve the implementation (e.g. allowing a Command in backend-context as well as CLI, or adapting a Fluid/TypoScript wrapper depending on context Web-Frontend vs PDF).
So the basic overhead is not implementation time, but having a bootstrap extension skeleton (which exists) and the necessary API knowledge (which should exist for integrators). So "quick and dirty" isn't really a valid reason.
Basically it IMHO boils down to NIH syndrome, which shouldn't need to be supported at all.
So only con's here.
来源:https://stackoverflow.com/questions/60317542/are-there-viable-usecases-for-using-standalone-php-scripts-in-a-typo3-site