Programmatically adding PHP generated TypoScript to the backend configuration

Today I’ve struggled with adding PHP generated TypoScript configuration to the backend. There doesn’t seem to be an API for this, unfortunately, so I had to dig a little bit into the TYPO3 source.

Turns out that t3lib_befunc#getPagesTSconfig, which is responsible for retrieving TypoScript configuration for the backend, makes use of the following global variable as the “default TypoScript configuration”:

$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']

So, being short of a proper API, I ended up simply appending my generated configuration to the defaultPageTSconfig string (in my ext_localconf.php file).

Is there a better way to achieve the same thing? If so, let me know :)

Installing NewRelic into MAMP on Mac OS X

Easy as pie if you know how to do it (actually this works for installing NewRelic anywhere that is not a standard Apache/PHP path) :)

  • Download the New Relic installer files (as a .tar.gz package)
  • Find out your MAMP PHP path (mine was /Applications/MAMP/bin/php/php5.3.6/bin)
  • Go to your unpacked new relic installer files and execute
sudo NR_INSTALL_PHPLIST='<your mamp php path>' ./newrelic-install
  • Follow the instructions in the installer (don’t forget to edit your php.ini, the installer gives you instructions on what to add)

And voilá, worked like a charm :)

PS: New Relic is kind of awesome!

Proper redirecting in TYPO3 (from within PHP)

Redirecting in PHP is easy:

$url = "http://coding-journal.com/";
header("Location: $url");

But there is tons of stuff to worry about when doing a header redirect, for instance:

  • What HTTP status will be sent?
  • Is the URL I’m throwing into the header-call really absolute?
  • Does my script exit after the header-call? (Because there should be no HTTP body if you send a Location: ... header and sending one may lead to unexpected behavior in some browsers).

    Continue reading

Hands on PHPFog Beta

Many of you may already be familiar with cloud platforms such as Heroku and Google App Engine which allow you to easily deploy scalable web applications with a minimal administration effort. Today I’ll be checking out PHPFog, a new cloud platform for (you guessed it) PHP.

Continue reading