SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Downloaden Sie, um offline zu lesen
Debugging, Monitoring and
Profiling


Fabrizio Branca
fabrizio (dot) branca (at) aoemedia (dot) de
Twitter: @fbrnc
This talk is…

   •   sharing some best practices
   •   sharing some tools with you
   •   an (incomplete) checklist
   •   a reminder (hopefully)




Fabrizio Branca
What is this all about?

   • Make your website run smoothly!
        • during development…
        • and when the site is online

   • “Smoothly” is
        • No bugs (unexpected behaviour)
        • Stability
        • Performance
Fabrizio Branca
This talk is about

   How to…
   • avoid errors
   • detect errors
   • deal with errors
   • notify yourself when errors have occurred


Fabrizio Branca
It„s all about bugs




Fabrizio Branca
It„s all about bugs

   Everybody creates bugs. Nobody is perfect.

   A high percentage of coding time goes into
   • searching for bugs
   • fixing bugs


   Increase your productivity by reducing this time!

Fabrizio Branca
Automating

   • Automatize error recognition
        • Use proper tools
   • Automatize error reporting
        • Route detailed error reports into your mailbox




Fabrizio Branca
Bugs

   • Avoid bugs
        • through programming style
   • Spot bugs fast
        • “Safety nets”: Unit tests, Assertions
   • Detect them before the customer and/or
     the website user finds them


Fabrizio Branca
Avoid bugs

• Use a proper IDE
  • Syntax checks

  • Code Completion
Coding style
   •   Cover all cases: No if without else!
   •   Use type hints wherever possible
   •   Stick to patterns
   •   Increase crearity
   •   Convention over configuration
   •   KISS
   •   Use object collections
   •   Make it easier for team members to find and fix bugs
       (increase the truck factor) by sticking to coding
       guidelines and patterns
Fabrizio Branca
What does PHP offer?

   • log_errors
   • display_errors
   • error_log

   Set values in
   • php.ini
   • .htaccess / vhost configuration
Fabrizio Branca
What does TYPO3 offer?

   •   devLog, sysLog, Tslog
   •   devIpMask
   •   Deprecation log
   •   Page not found / Page unavailable
   •   Exception handling
   •   Error handling
   •   Debug Console in the BE
Fabrizio Branca
Deal with exceptions (I)

   How to react when an exception has
     occurred?
   • Don„t display any details to the user!
   • Send a correct HTTP status code (for
     search engines and log files)
   $GLOBALS['TSFE']->pageNotFoundAndExit($errorHandlerMessage);
   $GLOBALS['TSFE']->pageUnavailableAndExit($errorHandlerMessage);



Fabrizio Branca
Page not found




Fabrizio Branca
Page unavailable




Fabrizio Branca
Deal with exceptions (II)

   Handle exceptions within your controllers.

   Notify yourself:
   • write a message to devLog
   • write a message to sysLog
   • write a message to TSLog

Fabrizio Branca
Exception Handler




Fabrizio Branca
Bug detection

   • Bugs are harder to fix the later they are
     detected
   • Bugs become harder to diagnose the
     further the symptom is removed from the
     cause



Fabrizio Branca
Bug detection with assertions

   • Make sure that variables contain what you
     expect at any time (e.g. after calling a function)
   • E.g.: Check incoming parameters for correct
     type
   • Simple one line call:
       tx_pttools_assert::isValidUid($this->params['uid']);
   • Throws an exception if assertion is not true
   •   http://articles.sitepoint.com/article/bug-detection-php-assertions
       http://debuggable.com/posts/assert-the-yummyness-of-your-cake:480f4dd6-
       7fe0-4113-9776-458acbdd56cb
Fabrizio Branca
Bug detection with assertions

   • Assertions are easy to use.
   • Don„t assume anything, check it!
        • Example: ini_set()
   • No substitute for unit tests!




Fabrizio Branca
Bug detection with assertions

   See
       EXT:pt_tools/res/staticlib/class.tx_pttools_assert.php

   or
       build your own assert class



   Some examples:
   • tx_pttools_assert::isValidUid();
   • tx_pttools_assert::isNotEmptyString();

Fabrizio Branca
t3lib_div::devLog()




Fabrizio Branca
t3lib_div::sysLog()

   Decides by configuration how to handle
     syslog messages
   • send mail
   • write to log file
   • write to OS syslog



Fabrizio Branca
Custom SysLog Handler

   See
       EXT:tcaobjects/res/class.tx_tcaobjects_syslog.php




Fabrizio Branca
SysLog notification mail
msg: Assertion "isValidUid" failed!
extKey: pt_tools
severity: 3
exceptionClass: tx_pttools_exceptionAssertion
debugMsg:
  file: /var/www/burghalle/integration/htdocs/typo3conf/ext/aoe_burg/controller/class.tx_aoeburg_controller_extranet.php
  line: 78
  function: tx_aoeburg_controller_extranet::init
  assertType: isValidUid
  val:
  expected: 1
Server:
  TYPO3_REQUEST_URL: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-
      bearbeiten/e/typo3conf/ext/burghalle_template/i/white-75.png
  HTTP_REFERER: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-bearbeiten/e/saveContent.html
  POST: -- none --
  COOKIE:
    condensed: 0
    fe_typo_user: 6b7ccec749891321cb6e7e2fc4c685a4
    PHPSESSID: 4b8712f5a4c845029da1f2332cf9132b
Client:
  HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4 ( .NET CLR
      3.5.30729; .NET4.0C)
  Spider: No
  REMOTE_HOST: [null]
  REMOTE_ADDR: 217.19.187.106
User:
  FE_User: aoe
  BE_User: -- no user --
Trace: [...]
$TYPO3_DB-
   >debug_check_recordset()
   • Check all database queries
   • Debug_check_recordset takes care of
     writing log messages




Fabrizio Branca
TSlog




Fabrizio Branca
$TT->push() / ->pull()

   Use the timetrack object to keep track of
    what happens in your code.




Fabrizio Branca
Reports module




Fabrizio Branca
Reports module

   Write your own reports
   Examples:
   • Table size
   • Outdated extensions (extension manager)
   • TCA Integrity
   • TCA/database integrity (Like Compare tool)
   • Extension integrity (dependencies, conflicts)
   • Free disk space
   • Server load

Fabrizio Branca
Define a strong api

   • Provide interfaces for hooks.
   • Allow alternatives (pagerStrategy,
     viewClass,…)




Fabrizio Branca
Keep an eye on the logs…

   • Webserver
        • Apache error log
        • PHP error log
   • TYPO3
        • Log module (Core error handler…)
        • Admin Panel
        • RealUrl
              • error log
              • are all paramters encoded?
        • Deprecation log
        • Reports module
Fabrizio Branca
Keep an eye on the logs…

   • External tools
        • Google Webmaster Tools
        • Wget
        • Piwik
   • MySQL
        • Slow query log
   • OS (*nix)
        • Syslog

Fabrizio Branca
Log Module




Fabrizio Branca
Google Webmaster Tools




Fabrizio Branca
Let tools do the analysis

   •   PHP
   •   TSFE
   •   TypoScript
   •   jQuery code
   •   HTML
   •   CSS
   •   RSS
Fabrizio Branca
Visualizing xdebug profiling
Visualizing xdebug profiling
Visualizing pdepend xml
jQuery Lint

   „Runtime Reporter“
   http://james.padolsey.com/javascript/jquery-lint/




Fabrizio Branca
TypoScript Check (lint)

   Proof of concept!
   Xclassing tslib_content:

   function stdWrap($content,$conf) {
          $this->getLinkChecker()->check($conf, 'stdWrap');
          return parent::stdWrap($content, $conf);
   }



Fabrizio Branca
Tick
Tick




Fabrizio Branca
Tick
Use validators

   Use validators for validating
   • HTML
   • CSS
   • RSS

   Keep an eye on editor„s content

Fabrizio Branca
Spot performance killers

   • Use USER_INTs only if really needed.
   • Create links with cHashes
   • Avoid putting USER_INTs on all pages
     (load them via ajax)
        • Cache headers
        • Static publishing


Fabrizio Branca
Monitoring

   • Configure your TYPO3 instances to notify
     you when errors occur.
   • Use Monitoring tools (e.g. Nagios,
     Caretaker?)




Fabrizio Branca
Pingdom
Maintainance

   • Delete old temp files
       find ../htdocs/typo3temp -type f -mtime +28 -delete
   • Delete deleted records
   • Delete unreferenced files
   • Cleanup/check database



Fabrizio Branca

Weitere ähnliche Inhalte

Was ist angesagt?

Jakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix toolsJakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
DevSecCon
 

Was ist angesagt? (20)

From 0 to 0xdeadbeef - security mistakes that will haunt your startup
From 0 to 0xdeadbeef - security mistakes that will haunt your startupFrom 0 to 0xdeadbeef - security mistakes that will haunt your startup
From 0 to 0xdeadbeef - security mistakes that will haunt your startup
 
DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
 
Debugging NET Applications With WinDBG
Debugging  NET Applications With WinDBGDebugging  NET Applications With WinDBG
Debugging NET Applications With WinDBG
 
PHPUnit Automated Unit Testing Framework
PHPUnit Automated Unit Testing FrameworkPHPUnit Automated Unit Testing Framework
PHPUnit Automated Unit Testing Framework
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to rails
 
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix toolsJakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
 
Web Exploitation
Web ExploitationWeb Exploitation
Web Exploitation
 
Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017
 
Continous Delivering a PHP application
Continous Delivering a PHP applicationContinous Delivering a PHP application
Continous Delivering a PHP application
 
One commit, one release. Continuously delivering a Symfony project.
One commit, one release. Continuously delivering a Symfony project.One commit, one release. Continuously delivering a Symfony project.
One commit, one release. Continuously delivering a Symfony project.
 
Fuzzing - Part 2
Fuzzing - Part 2Fuzzing - Part 2
Fuzzing - Part 2
 
Java-Jersey 到 Python-Flask 服務不中斷重構之旅
Java-Jersey 到 Python-Flask 服務不中斷重構之旅Java-Jersey 到 Python-Flask 服務不中斷重構之旅
Java-Jersey 到 Python-Flask 服務不中斷重構之旅
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
 
DevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsDevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps Toolchains
 
Legal and efficient web app testing without permission
Legal and efficient web app testing without permissionLegal and efficient web app testing without permission
Legal and efficient web app testing without permission
 
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
Invoke-CradleCrafter: Moar PowerShell obFUsk8tion & Detection (@('Tech','niqu...
 
2020 ADDO Spring Break OWASP ZAP Automation
2020 ADDO Spring Break OWASP ZAP Automation2020 ADDO Spring Break OWASP ZAP Automation
2020 ADDO Spring Break OWASP ZAP Automation
 
Take a Stroll in the Bazaar
Take a Stroll in the BazaarTake a Stroll in the Bazaar
Take a Stroll in the Bazaar
 
Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk Automating OWASP ZAP - DevCSecCon talk
Automating OWASP ZAP - DevCSecCon talk
 
Obfuscating The Empire
Obfuscating The EmpireObfuscating The Empire
Obfuscating The Empire
 

Ähnlich wie Debugging, Monitoring and Profiling in TYPO3

Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
Volkan Özçelik
 
Abraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permissionAbraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permission
Yury Chemerkin
 
Technical Workshop - Win32/Georbot Analysis
Technical Workshop - Win32/Georbot AnalysisTechnical Workshop - Win32/Georbot Analysis
Technical Workshop - Win32/Georbot Analysis
Positive Hack Days
 

Ähnlich wie Debugging, Monitoring and Profiling in TYPO3 (20)

External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
DEFCON 23 - Jason Haddix - how do i shot web
DEFCON 23 - Jason Haddix - how do i shot webDEFCON 23 - Jason Haddix - how do i shot web
DEFCON 23 - Jason Haddix - how do i shot web
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal Site
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
Manual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugManual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A Bug
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Abraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permissionAbraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permission
 
Metasploitation part-1 (murtuja)
Metasploitation part-1 (murtuja)Metasploitation part-1 (murtuja)
Metasploitation part-1 (murtuja)
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
 
Technical Workshop - Win32/Georbot Analysis
Technical Workshop - Win32/Georbot AnalysisTechnical Workshop - Win32/Georbot Analysis
Technical Workshop - Win32/Georbot Analysis
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad Guys
 
Adversary Emulation and Cracking The Bridge – Overview EMERSON EDUARDO RODRIGUES
Adversary Emulation and Cracking The Bridge – Overview EMERSON EDUARDO RODRIGUESAdversary Emulation and Cracking The Bridge – Overview EMERSON EDUARDO RODRIGUES
Adversary Emulation and Cracking The Bridge – Overview EMERSON EDUARDO RODRIGUES
 
Testing mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP frameworkTesting mit Codeception: Full-stack testing PHP framework
Testing mit Codeception: Full-stack testing PHP framework
 

Mehr von AOE

Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
AOE
 
Searchperience Indexierungspipeline
Searchperience   IndexierungspipelineSearchperience   Indexierungspipeline
Searchperience Indexierungspipeline
AOE
 
High Performance Multi-Server Magento in der Cloud
High Performance Multi-Server Magento in der CloudHigh Performance Multi-Server Magento in der Cloud
High Performance Multi-Server Magento in der Cloud
AOE
 
Selenium 2 for PHP(Unit)
Selenium 2 for PHP(Unit)Selenium 2 for PHP(Unit)
Selenium 2 for PHP(Unit)
AOE
 
T3DD12 Caching with Varnish
T3DD12 Caching with VarnishT3DD12 Caching with Varnish
T3DD12 Caching with Varnish
AOE
 
T3DD12 community extension
T3DD12  community extensionT3DD12  community extension
T3DD12 community extension
AOE
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE
 

Mehr von AOE (20)

Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)
 
rock-solid TYPO3 development with continuous integration and deployment
rock-solid TYPO3 development with continuous integration and deploymentrock-solid TYPO3 development with continuous integration and deployment
rock-solid TYPO3 development with continuous integration and deployment
 
Agile Management - Best Practice Day der Deutschen Bahn am 17.10.2013
Agile Management - Best Practice Day der Deutschen Bahn am 17.10.2013Agile Management - Best Practice Day der Deutschen Bahn am 17.10.2013
Agile Management - Best Practice Day der Deutschen Bahn am 17.10.2013
 
Continuous Quality Assurance using Selenium WebDriver
Continuous Quality Assurance using Selenium WebDriverContinuous Quality Assurance using Selenium WebDriver
Continuous Quality Assurance using Selenium WebDriver
 
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
 
SONY on TYPO3 - Rapid Global CMS Deployment
SONY on TYPO3 - Rapid Global CMS DeploymentSONY on TYPO3 - Rapid Global CMS Deployment
SONY on TYPO3 - Rapid Global CMS Deployment
 
Cloud Deployment und (Auto)Scaling am Beispiel von Angrybird
Cloud Deployment und (Auto)Scaling  am Beispiel von AngrybirdCloud Deployment und (Auto)Scaling  am Beispiel von Angrybird
Cloud Deployment und (Auto)Scaling am Beispiel von Angrybird
 
Searchperience Indexierungspipeline
Searchperience   IndexierungspipelineSearchperience   Indexierungspipeline
Searchperience Indexierungspipeline
 
High Performance Multi-Server Magento in der Cloud
High Performance Multi-Server Magento in der CloudHigh Performance Multi-Server Magento in der Cloud
High Performance Multi-Server Magento in der Cloud
 
Selenium 2 for PHP(Unit)
Selenium 2 for PHP(Unit)Selenium 2 for PHP(Unit)
Selenium 2 for PHP(Unit)
 
Angrybirds Magento Cloud Deployment
Angrybirds Magento Cloud DeploymentAngrybirds Magento Cloud Deployment
Angrybirds Magento Cloud Deployment
 
T3DD12 Caching with Varnish
T3DD12 Caching with VarnishT3DD12 Caching with Varnish
T3DD12 Caching with Varnish
 
T3DD12 community extension
T3DD12  community extensionT3DD12  community extension
T3DD12 community extension
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Panasonic search
Panasonic searchPanasonic search
Panasonic search
 
Performance durch Caching
Performance durch CachingPerformance durch Caching
Performance durch Caching
 
Performance durch Caching
Performance durch CachingPerformance durch Caching
Performance durch Caching
 
Open Source CMS TYPO3 at Cisco WebEx
Open Source CMS TYPO3 at Cisco WebExOpen Source CMS TYPO3 at Cisco WebEx
Open Source CMS TYPO3 at Cisco WebEx
 
Case Study NDD Distribution on TYPO3
Case Study NDD Distribution on TYPO3Case Study NDD Distribution on TYPO3
Case Study NDD Distribution on TYPO3
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Debugging, Monitoring and Profiling in TYPO3

  • 1. Debugging, Monitoring and Profiling Fabrizio Branca fabrizio (dot) branca (at) aoemedia (dot) de Twitter: @fbrnc
  • 2. This talk is… • sharing some best practices • sharing some tools with you • an (incomplete) checklist • a reminder (hopefully) Fabrizio Branca
  • 3. What is this all about? • Make your website run smoothly! • during development… • and when the site is online • “Smoothly” is • No bugs (unexpected behaviour) • Stability • Performance Fabrizio Branca
  • 4. This talk is about How to… • avoid errors • detect errors • deal with errors • notify yourself when errors have occurred Fabrizio Branca
  • 5. It„s all about bugs Fabrizio Branca
  • 6. It„s all about bugs Everybody creates bugs. Nobody is perfect. A high percentage of coding time goes into • searching for bugs • fixing bugs Increase your productivity by reducing this time! Fabrizio Branca
  • 7. Automating • Automatize error recognition • Use proper tools • Automatize error reporting • Route detailed error reports into your mailbox Fabrizio Branca
  • 8. Bugs • Avoid bugs • through programming style • Spot bugs fast • “Safety nets”: Unit tests, Assertions • Detect them before the customer and/or the website user finds them Fabrizio Branca
  • 9. Avoid bugs • Use a proper IDE • Syntax checks • Code Completion
  • 10. Coding style • Cover all cases: No if without else! • Use type hints wherever possible • Stick to patterns • Increase crearity • Convention over configuration • KISS • Use object collections • Make it easier for team members to find and fix bugs (increase the truck factor) by sticking to coding guidelines and patterns Fabrizio Branca
  • 11. What does PHP offer? • log_errors • display_errors • error_log Set values in • php.ini • .htaccess / vhost configuration Fabrizio Branca
  • 12. What does TYPO3 offer? • devLog, sysLog, Tslog • devIpMask • Deprecation log • Page not found / Page unavailable • Exception handling • Error handling • Debug Console in the BE Fabrizio Branca
  • 13. Deal with exceptions (I) How to react when an exception has occurred? • Don„t display any details to the user! • Send a correct HTTP status code (for search engines and log files) $GLOBALS['TSFE']->pageNotFoundAndExit($errorHandlerMessage); $GLOBALS['TSFE']->pageUnavailableAndExit($errorHandlerMessage); Fabrizio Branca
  • 16. Deal with exceptions (II) Handle exceptions within your controllers. Notify yourself: • write a message to devLog • write a message to sysLog • write a message to TSLog Fabrizio Branca
  • 18. Bug detection • Bugs are harder to fix the later they are detected • Bugs become harder to diagnose the further the symptom is removed from the cause Fabrizio Branca
  • 19. Bug detection with assertions • Make sure that variables contain what you expect at any time (e.g. after calling a function) • E.g.: Check incoming parameters for correct type • Simple one line call: tx_pttools_assert::isValidUid($this->params['uid']); • Throws an exception if assertion is not true • http://articles.sitepoint.com/article/bug-detection-php-assertions http://debuggable.com/posts/assert-the-yummyness-of-your-cake:480f4dd6- 7fe0-4113-9776-458acbdd56cb Fabrizio Branca
  • 20. Bug detection with assertions • Assertions are easy to use. • Don„t assume anything, check it! • Example: ini_set() • No substitute for unit tests! Fabrizio Branca
  • 21. Bug detection with assertions See EXT:pt_tools/res/staticlib/class.tx_pttools_assert.php or build your own assert class Some examples: • tx_pttools_assert::isValidUid(); • tx_pttools_assert::isNotEmptyString(); Fabrizio Branca
  • 22.
  • 24. t3lib_div::sysLog() Decides by configuration how to handle syslog messages • send mail • write to log file • write to OS syslog Fabrizio Branca
  • 25. Custom SysLog Handler See EXT:tcaobjects/res/class.tx_tcaobjects_syslog.php Fabrizio Branca
  • 26. SysLog notification mail msg: Assertion "isValidUid" failed! extKey: pt_tools severity: 3 exceptionClass: tx_pttools_exceptionAssertion debugMsg: file: /var/www/burghalle/integration/htdocs/typo3conf/ext/aoe_burg/controller/class.tx_aoeburg_controller_extranet.php line: 78 function: tx_aoeburg_controller_extranet::init assertType: isValidUid val: expected: 1 Server: TYPO3_REQUEST_URL: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel- bearbeiten/e/typo3conf/ext/burghalle_template/i/white-75.png HTTP_REFERER: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-bearbeiten/e/saveContent.html POST: -- none -- COOKIE: condensed: 0 fe_typo_user: 6b7ccec749891321cb6e7e2fc4c685a4 PHPSESSID: 4b8712f5a4c845029da1f2332cf9132b Client: HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4 ( .NET CLR 3.5.30729; .NET4.0C) Spider: No REMOTE_HOST: [null] REMOTE_ADDR: 217.19.187.106 User: FE_User: aoe BE_User: -- no user -- Trace: [...]
  • 27. $TYPO3_DB- >debug_check_recordset() • Check all database queries • Debug_check_recordset takes care of writing log messages Fabrizio Branca
  • 29. $TT->push() / ->pull() Use the timetrack object to keep track of what happens in your code. Fabrizio Branca
  • 31. Reports module Write your own reports Examples: • Table size • Outdated extensions (extension manager) • TCA Integrity • TCA/database integrity (Like Compare tool) • Extension integrity (dependencies, conflicts) • Free disk space • Server load Fabrizio Branca
  • 32. Define a strong api • Provide interfaces for hooks. • Allow alternatives (pagerStrategy, viewClass,…) Fabrizio Branca
  • 33. Keep an eye on the logs… • Webserver • Apache error log • PHP error log • TYPO3 • Log module (Core error handler…) • Admin Panel • RealUrl • error log • are all paramters encoded? • Deprecation log • Reports module Fabrizio Branca
  • 34. Keep an eye on the logs… • External tools • Google Webmaster Tools • Wget • Piwik • MySQL • Slow query log • OS (*nix) • Syslog Fabrizio Branca
  • 36.
  • 38. Let tools do the analysis • PHP • TSFE • TypoScript • jQuery code • HTML • CSS • RSS Fabrizio Branca
  • 42. jQuery Lint „Runtime Reporter“ http://james.padolsey.com/javascript/jquery-lint/ Fabrizio Branca
  • 43. TypoScript Check (lint) Proof of concept! Xclassing tslib_content: function stdWrap($content,$conf) { $this->getLinkChecker()->check($conf, 'stdWrap'); return parent::stdWrap($content, $conf); } Fabrizio Branca
  • 44. Tick
  • 46. Tick
  • 47. Use validators Use validators for validating • HTML • CSS • RSS Keep an eye on editor„s content Fabrizio Branca
  • 48. Spot performance killers • Use USER_INTs only if really needed. • Create links with cHashes • Avoid putting USER_INTs on all pages (load them via ajax) • Cache headers • Static publishing Fabrizio Branca
  • 49. Monitoring • Configure your TYPO3 instances to notify you when errors occur. • Use Monitoring tools (e.g. Nagios, Caretaker?) Fabrizio Branca
  • 51. Maintainance • Delete old temp files find ../htdocs/typo3temp -type f -mtime +28 -delete • Delete deleted records • Delete unreferenced files • Cleanup/check database Fabrizio Branca