PHP Composer update “cannot allocate memory” error (using Laravel 4)

I just can’t solve this one. I’m on Linode 1G RAM basic plan. Trying to install a package via Composer and it’s not letting me. My memory limit is set to “-1” on PHP.ini Is there anything else I can do to get this installed? Loading composer repositories with package information Updating dependencies (including require-dev) … Read more

Best way to test for a variable’s existence in PHP; isset() is clearly broken

From the isset() docs: isset() will return FALSE if testing a variable that has been set to NULL. Basically, isset() doesn’t check for whether the variable is set at all, but whether it’s set to anything but NULL. Given that, what’s the best way to actually check for the existence of a variable? I tried … Read more

Unexpected results when working with very big integers on interpreted languages

I am trying to get the sum of 1 + 2 + … + 1000000000, but I’m getting funny results in PHP and Node.js. PHP $sum = 0; for($i = 0; $i <= 1000000000 ; $i++) { $sum += $i; } printf(“%s”, number_format($sum, 0, “”, “”)); // 500000000067108992 Node.js var sum = 0; for (i … Read more

Doctrine – How to print out the real sql, not just the prepared statement?

We’re using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select(‘id’)->from(‘MyTable’); and then in the function I’m adding in various where clauses and things as appropriate, like this $q->where(‘normalisedname = ? OR name = ?’, array($string, $originalString)); Later on, before execute()-ing that query object, I want to print out the … Read more