Troels has been crafting web applications, as a freelancer and while employed by companies of various sizes, since around the time of the IT-bubble burst. Nowadays, he's working on backend systems for a Danish ISP. In his spare time, he develops and maintains Konstrukt, a web application framework for PHP, and is the organizer of a monthly PHP-meetup in Copenhagen.

Troels's articles

  1. Interactive CLI password prompt in PHP

    Just a quick tip, since I spent a good hour figuring this out recently. PHP has no native way of doing an interactive password prompt, when running as CLI. You can however use bash for the task. Of course this means that it won’t work on Windows, but you should be fine on most anything […]

  2. Flowing Markdown Upstream

    Markdown is one of the most popular alternatives to writing markup — partly because it’s easy to understand for non-technical users. Here, Troels introduces an implementation that includes a live preview.

  3. How to Expose PHP’s Private Parts

    I’ve been tinkering with dumping PHP objects, and have found myself constantly running into a brick wall. The output from print_r and friends is fine in some contexts, but for larger structures, it would be nice to tidy the output up a bit and wrap it in some HTML.

  4. DOM vs. Template

    Fredrik Holmström recently posted a small template engine, based on DOM-manipulation. While there are certainly a lot of template engines around, I find this approach interesting. The concept is simple enough; The template is parsed into an object model (DOM), and then values can be assigned to these through PHP code. The main difference to […]

  5. Keeping Current With PHP

    Just a quick hint to people with an interest in the development of PHP, but no time for following php-internals. Since March, there has been a wiki at wiki.php.net. The most interesting section is probably wiki.php.net/rfc, which – as the name implies – contains RFC‘s for improvements of the language. I’ve rambled on about closures […]

  6. Debugging PHP

    I just checked in a little project, I’ve been working on for the last couple of weeks. It really begun at the last Copenhagen php-meetup; Joakim Nygård and Jacob Oettinger made a presentation of their project, WebCacheGrind. I casually mentioned something about having played with the dbgp-protocol (The debugging part of Xdebug) and that it […]

  7. Useful in-browser development tools for PHP

    While debuggers exists, there isn’t much of a tradition for using them in PHP. People have largely come to rely on injecting debugging code directly into the program, for inspecting program scope. The infamous var_dump have served for this purpose and version 4.3.0 of PHP brought us another equally useful function — debug_backtrace. Tracers and […]

  8. What’s so bad about the Singleton?

    I keep running into people who caution against using Singleton and recommend to avoid it like a plague. What is so scary about it? — Kailash Badu It’s a good question, for it is true that global variables are often demonised and more recently the Singleton has befallen the same fate. Perhaps a bit surprising, […]

  9. Dealing with Dependencies

    Compositional programming style In the object oriented programming style, it’s preferable to split functionality out to multiple objects, that can work together to solve a single task. Taken to the extreme, this results in more, but smaller, classes and generally relies less on inheritance and more on composition. In lack of better words, I’ll call […]

  10. Lexical scope to appear in PHP?

    I mentioned briefly, in my last post, that Wez Furlong made a patch back in March, that allows a native syntax for creating anonymous functions. This could replace the heinous create_function. Since then, I brought up Wez’ original patch again on the php-internals lists. This has prompted some hefty debate over the last week. The […]

  11. The state of functional programming in PHP

    With the rise of Javascript, and languages like Python and Ruby, functional programming is becoming more mainstream. Even Java seems to be getting closures in the next version, so does this leave PHP lacking behind or is there an unrealised potential hidden within? Dynamic dispatch What exactly defines a functional programming language, is perhaps an […]

  12. PHP Manual CLI style 2.0

    Harry mentioned the handy little phpm some three years ago. And Sean Coates was kind enough to point out how it could be replaced with a shell one-liner. Doesn’t that just make one love bash? One thing, I missed with either of the two, was the ability to see the entire manual entry. It’s quite […]

  13. Index of PHP tokens for Emacs and beyond

    I’ve been using Emacs as my primary editor for a while now. A lot of people prefer IDE’s, but I’ve never been comfortable with them. I kind of like the ability to show a list of classes & functions in a file though. Emacs can use ctags to generate a list of tokens for a […]

  14. Dynamic global functions in PHP

    Like many others, I prefer to use procedural PHP as a template language. While PHP’s syntax makes it a practical choice for this, there is a problem with embedding dynamic content. Most PHP applications produce HTML output, so you end up writing <?php echo htmlspecialchars($foo);?> a lot, using this technique. Or you forget it, and […]