I do have a PHP script, which is not an extension for Typo3. Now I would like to delete the whole Cache of Typo3 out of this script. How is that possible?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
in typo3 6.x extbase its simple.
Edit : clearPageCache is not static then you need to create object of CacheService
TYPO3\CMS\Extbase\Service\CacheService::clearPageCache(pageUid);
TYPO3 6.x
first initialize the Service in your Class
in your function just call
while $pids is an integer (for single page) or array of integers (multiple pages)
see: http://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_service_1_1_cache_service.html
In TYPO3 since 4.5 (I think) its a static method so you have just to call
in your controller.
Found it here: http://www.phpkode.com/source/p/typo-cms/typo3_src+dummy-4.6.5/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php
UPDATE
From TYPO3 7 on you can also install Helmut Hummels Extension typo3_console. Then you can clear the cache like:
https://extensions.typo3.org/extension/typo3_console/
https://github.com/TYPO3-Console/TYPO3-Console
I found the solution myself and its actually pretty easy. I took a look into the class.t3lib_tcemain.php in the t3lib folder. There you've got the necessary commands to clear the cache. It also checks, if you have the cachingframework enabled. If so, you need to truncate a few other tables as well (Starts with cachingframework_cache_)
It is basically:
In FLOW3 there is a possibility to do such stuff, as far as I know with TYPO3 v.4.x You have no such default CLI option, so You should use or You own script, or use such extensions as cleartypo3cache or Cli Cleaner.
Also I made a bash script to clean cache tables of Your dB : https://gist.github.com/fedir/5162747
For removing all the cache form TYPO3,
You have to TRUNCATE database tables that contains cache data. They are : cache_treelist cache_pagesection cache_hash cache_pages
Then you also have to empty 'typo3temp' folder to clear major cache from TYPO3. For that you can use external script like given in the below link.
http://typo3techie.blogspot.in/2014/05/cleartemp-clear-typo3temp-for-removing.html
Install Extension "
cleartypo3cache
" and create the BE user "_cli_cleartypo3cache
" and add the following TSconfig:Now test if cache is cleared:
If your webserver is on localhost, you are lucky because you don't need this shell script. If your webserver is on a remote host, you need an additional wrapper script. This is because PhpStorm does not provide an environment variable for the remote host directory. You have to set this directory statically for each project in the wrapper script:
Save this file in your project file directory into .idea/clear-typo3-cache.sh and make it executable:
PhpStorm External Tools You need to create an "external tool" in PhpStorm to be able to clear cache.
Remote host scenario
Add the following line to "Programm:"
Localhost scenario
Add this line to "Program:"
Add this line to "Parameters:"
You need to have a PHP interpreter configured in PhpStorm-->Settings-->PHP to use $PhpExecutable$. Alternatively you can use /usr/bin/php http://www.t3node.com/fileadmin/user_upload/images/phpstorm-external-tools-typo3-cache.png
PhpStorm Keymap I suggest to use the same key binding as you use for saving or remote host uploading:
Go to PhpStorm-->Settings-->Keymap
For remote host scenario, navigate to: Main menu-->Tools-->Deployment-->Upload to Default Server. Notice the existing shortcut. If you don't have one for that, create a new one (I use ALT+SHIFT+U) For the localhost scenario, just use Ctrl+S (Main menu-->File-->Save All).
Now PhpStorm will warn you that the shortcut is already in use for a different command. That's fine, it's exactly what we want to have.
That's it. Your TYPO3 caches are always cleared when you hit save or upload on your keyboard.
adapted from t3node