Extension Development
<< Back to Developer manuals page
You find all the different extension development manuals either by the extensions themself or in the TYPO3 documentation matrix.A good place to start is the Extension Developers Guide (XDG)
Development mini howto
This is a small howto showing you how to start developing for TYPO3.
Development environments
- Get a PHP development environment
Database development
- Use a tool like fabFORCE DBDesigner4 or MySQL Workbench to draw your database tables and the relationships among them.
Documentation
- Read the TYPO3 API Documentation.
- API overview
- Install the extdeveval
or the newer (in development, requires fn_lib extension) t3dev. It gives you the APIs for extensions and a link list to documentation.
- Search in the Namazu: Full-Text Search Engine.
- Follow the Project Coding Guidelines
- Extension Development, using Flexforms
- Backend Programming
- Translate and document your extension following the TYPO3.org - manual for developers (How typo3.org works)
- Use the Documentation template for yor extension documentation Documentation template
External resources
- Read the PHP manual.
The source code
- Get the source code for TYPO3 core: TYPO3 Content Management Framework
- Get the source code for TYPO3 extensions: TYPO3 Extension Development Platform
- Browse the source code for TYPO3 core: TYPO3 core Git repository browser
- Browse the source code for TYPO3 extensions: TYPO3 extension SVN repository browser
Classes and functions
- $GLOBALS['TSFE') the main front end class, can be found in typo3/sysext/cms/tslib/tslib/class.tslib_fe.php
- Use parseFunc() to convert text from input to disallow HTML tags or allow only those the from the allowTags setting.
if (is_array($this->conf['parseFunc.'])) { $markerArray['###PRODUCT_NOTE###'] = $this->cObj->parseFunc($markerArray['###PRODUCT_NOTE###'], $this->conf['parseFunc.']); }
Flexforms
- If you wish to use flexforms in your extension, follow the Using Flexforms guide.
Multiple Languages
- Create XML language files to support multiple languages. Use the locallang-XML translation tool to convert php language files into XML and do some cleanings.
- Create overlay tables which contain only the fields which need translations. Use the Table Library to create SQL queries which hides the language overlay tables to the developer.
Unix
- Use this command line to search for a pattern in many files under *nix
cd directory-of-sources find . -name '*.php' -exec grep -ni 'your search string' {} \; -ls
find . -name '*.php' -exec grep "\$GLOBALS\['TSFE'\]" {} \; -ls
- Or, man grep and see if your installed grep can do something like:
grep -rniH --include '*php' 'your search string' directory-of-sources
- The Linux cheat sheet lists some commands for frequent tasks under Linux (most of these should also work under other flavors of Unix)
Database
To access the database, use the Database Abstraction Layer. DBAL
To enable database access debug output, open typo3/t3lib/class.t3lib_db.php and change the line:
var $debugOutput = false;
to
var $debugOutput = true;
function debug($func) { error_log($this->debug_lastBuiltQuery, 0); }
You can also configure TYPO3 to output failed database queries to the browser.
- Either by using the Install Tool: In the section 'All Configuration', set [SYS][sqlDebug] = 1
- Or in typo3conf/localconf.php or somewhere in the code of your own extensions: $TYPO3_CONF_VARS['SYS']['sqlDebug'] = 1;
Global variables
- A quick way to access the most important global variables is the following piece of PHP:
global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
Use libraries and APIs
please add the ones you like. --Daniel Brüßler 11:03, 4 June 2007 (CEST)
- meta_feedit
- rlmp_dateselectlib
date selector, calendar javascript - rgfolderselector
folder selector field for the backend - div
Static methods for extensions. It has copies of itself as div<year> for each year in order to allow many versions of it at a time.
Caching issues
- read how to manage the cache - Caching and The Mysteries Of &cHash
- How to avoid the no_cache parameter? Proper Caching
- Generally you have to use the extension variable like 'tx_myext_pi_name[variable]'.
- You can also define standalone parameters e.g. for 'begin_at', 'offset' and similars for which the cHash parameter will get created using these functions:
- tslib_pibase::pi_getPageLink()
- t3lib_div::cHashParams()
- tslib_fe::makeCacheHash()
Blocking errors
- If TYPO3 stops working due to your coding, just view the entries of the log file. (*nix: /var/log/messages, /var/log/httpd/error_log, ...) and search for the string 'PHP Fatal error'.
HTML output into a file
To debug errors, it would be useful if TYPO3 also saves the HTML output into a file. Modify the printContent output function to save each page into the file typo3.log.
# typo3/alt_main.php: /** * Outputs the accumulated content to screen and into a file * * @return void */ function printContent() { echo $this->content; $handle = fopen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT').'/typo3conf/','wb'); fwrite ($handle, $this->content); fclose($handle); }
Standards
Take care of standards to make all TYPO3 extensions look very similar. This helps that others can easier understand your extensions and find the files in it. Standardization. These are the current recommendations. And you are invited to make your own proposals. All things which are needed in several extensions should be defined by the same names. So the setup for one extensions could be used 1:1 for another extension as well.