Currently browsing category

PHP

ircmaxell Framework Fixation An Anti Pattern

ircmaxell: Framework Fixation – An Anti Pattern ircmaxell: Framework Fixation – An Anti Pattern, short summary: delegation of architecture decisions to frameworks may not be optimal or even wrong only use frameworks when doing prototypes or projects you don’t need to maintain frameworks don’t save time/money in the long term …

Using V8 Javascript engine as a PHP extension update write PHP session

Using V8 Javascript engine as a PHP extension (update: write PHP session) pre { background-color:#444; white-space:pre-wrap; font-size:85%; padding:0px 6px; } “We Are Borg PHP. We Will Assimilate You. Resistance Is Futile!” Just got to something described as: This extension embeds the V8 Javascript Engine into PHP. It is called v8js …

MySQL or MySQLi or PDO

MySQL or MySQLi or PDO pre { background-color:#444; white-space:pre-wrap; font-size:84%; padding:0px 6px; } Lessons learned: MySQLi is 50 percent faster than MySQL when fetching more than 1000 datasets MySQLi is 100 percent slower than MySQL when fetching less than 1000 datasets PDO is 15-300 percent slower than MySQLi (value increases …

ircmaxell Is Autoloading A Good Solution

ircmaxell: Is Autoloading A Good Solution? ircmaxell: Is Autoloading A Good Solution?: at a 75% class usage tradeoff point, it doesn’t really make sense not to autoload, especially given all of the other benefits. So in the end, it looks like autoloading is indeed a good solution…From the comments: Simply …

Decorator or Subclassing

Decorator or Subclassing? pre { background-color:#444; white-space:pre-wrap; font-size:85%; padding:0px 6px; } Using anonymous functions in PHP is very nice to implement a decorator, but what about performance? Results: Subclassing is 40 percent faster than using a decorator Subclassing might require a bit more code Here is the code: class App …

How to implement i18n without performance overhead

How to implement i18n without performance overhead pre { background-color:#444; white-space:pre-wrap; font-size:85%; padding:0px 6px; } i18n is always difficult to implement and costs a lot performance. Normally, implementations use gettext() or a custom t()-function to translate a string. t() searches a INI or XML file for a translation key and …

Array key lookup isset or arraykeyexists or

Array key lookup: isset() or array_key_exists() or @ ? pre { background-color:#444; white-space:pre-wrap; font-size:85%; padding:0px 6px; } Lessons learned: isset() is faster than array_key_exists() array_key_exists() is faster than @ @ is slower than ignoring notices with error_reporting() Here is the code running on a 1.4 GHz machine with PHP 5.4.0: …

PHP Deployment with Dropbox

PHP Deployment with Dropbox pre { background-color:#444; white-space:pre-wrap; font-size:85%; padding:0px 6px; } Deploying files over sFTP or scp is boring and takes a lot of time. Using git with commit-hooks to initiate the deployment process is comfortable, but there is a solution that’s even faster: Deploy your server(s) with a …

Development Principles Think first programming

Development Principles – Think first programming A professor once told me:Remember, a string goes into the server, a string goes out. Not more, not less. So let’s ask the following questions: do you need a seven tier architecture? do you need to write a servlet container in PHP? do you …

Disadvantages of ORM

Disadvantages of ORM ORM has attracted a lot of attention in the last years. So let’s get a bit deeper into it.The biggest advantage of ORM is also the biggest disadvantage: queries are generated automatically queries can’t be optimized queries select more data than needed, things get slower, more latency(some …

For or Foreach? PHP vs. Javascript, C++, Java, HipHop

Lessons learned: Foreach is 4-5 times faster than For Nested Foreach is 4-5 times faster than nested For Foreach with key lookup is 2 times slower than Foreach without C++ is 5-10 times faster than PHP running For/Foreach on Arrays Javascript is 2-3 times slower than C++/Java running For on …

Things you should not do in PHP

Here is a list of things you should not do in PHP. Most of the stuff is pretty obvious, but over the years I’ve seen a lot of them. In most cases, these problems remain hidden until data grows above 10000 entries. So on a development system, things are always …

PHP memory consumption with Arrays and Objects update generators

PHP memory consumption with Arrays and Objects (update: generators) pre { background-color:#444; white-space:pre-wrap; font-size:90%; padding:0px 6px; } Lessons learned: objects need more memory than arrays (+ 2-10 percent) comparing 32bit to 64bit systems, memory consumption increases by 100-230 percent if array values are numeric, don’t save them as strings! saving …