Install intl PHP extension for MAMP / Symfony2

Published in: 

Many Bothans died to bring us this information (or at least my patience died a small death). Stashing this here for next time and/or to help someone else hopefully.

First do:

export PATH=/Applications/MAMP/bin/php/php5.3.14/bin/:$PATH
brew update
brew install icu4c

Next download PHP source that matches your MAMP version.


cd /Applications/MAMP/bin/php/php5.3.14
mkdir include
mv ~/Downloads/php-5.3.14 include/php
cd include/php
sudo ./configure
pecl install intl

Finally, add "" to your php.ini and restart Apache

20 March, 2010

Simple cross-browser Xdebug helper. Session starter and stopper, no add-ons needed.

During a recent browser upgrade I found myself stuck in a bit of a corner. The Firefox add-on I had been using, Xdebug Helper, was discontinued, and the supposed replacement add-on for it didn't work correctly.

Since the functionality of this now-defunct add-on made my life a lot easier (e.g., don't have to manually append/strip '?XDEBUG_SESSION_START=default' in my browser all day long to start/stop debugging sessions) I took it upon myself to keep this functionality and perhaps get rid of yet-one-more-add-on (which pays off when upgrade time comes).

In all their simplicity, here are two bookmarklets you can use to start and stop a Xdebug session in your browser of choice. Note that if you are using a custom proxy key value then you'll need to change the '=default' part in the bookmarklet to '=YourProxyKey'.

The 'start session' bookmark
Save this bookmark and then all you need to do to start a debugging session (assuming that you have Xdebug setup correctly and a breakpoint set in your code, of course) is to select the bookmark. I chose to put my bookmarks in the Toolbar at the top of window to make it even easier to get to. Also, just for the sake of posterity here is the code for the bookmark.

The 'stop session' bookmark
Save this bookmark and put it next to your 'start session' bookmark. When you're done with your session, simply click this bookmark and viola. Again, here is the code:
javascript:(function(){var currentUrl=location.href;var gotoUrl=currentUrl.replace("?XDEBUG_SESSION_START=default","");document.cookie='XDEBUG_SESSION=default;expires=Fri, 3 Aug 2001 20:47:11 UTC;host=none;path=/';location.href=gotoUrl;})();

1 February, 2010

Three little lines of code that you may learn to love

Assignment: Create a highly customized page/node in Drupal and:

  • Be able to develop the page/node using our text editor of choice and avoid the time-consuming and not-intended-to-be-developer friendly Drupal node-editing interface
  • Optionally be able to decide whether to have the page/node be editable by the via the Drupal UI or not.

Sure, we could do this by creating a page-node-xx.tpl.php template file (where 'xx' is the node id number), but that's just a major hassle later on when updating/theming things and it won't give us the flexibility of being able to let an end-user edit things.

In this case, the thing to do is to create a file called my-file.php (.php because we want our text-editor to still recognize it correctly), put it in our theme folder, check the PHP input filter on the node itself, and then place this code in a node:

// Include a file with the rendering of a node so that you can edit in text editor and just refresh without having to use Drupal UI
$filename = 'my-file.php';
$path_to_file = drupal_get_path('theme', 'your_themes_name') .'/'. $filename;

What this will do is look for the file you placed inside your theme folder called "my-file.php" and render it. Which means that you make changes directly to my-file.php without having to touch the node itself and thus simply refresh your node anytime you make changes to the file.

This method has the advantage of:

  • Saving a ton of time and headaches of dealing with the Drupal interface and doing without your favorite code editing tool.
  • After you're finished you'll have the option of choosing to replace the include-code with the final code inside your file so that an end-user can edit it within UI...
  • ...or you can just keep things like this and be able to do cool things like check the code into version control, which means that you basically get many of the benefits of a tpl.php file without the cost of one.

Enjoy and happy coding. :-)

UPDATE: if this all sounds like a good idea to you, head over to the project page for Save-to-File which was inspired by a conversation in the comment thread below.

22 March, 2008

Komodo IDE and Drupal/PHP development - a combo built upon mutual appreciation

After spending 3 days trying to get Elipse PDT and the Zend debugger working on Mac OS X, my nerves were very frayed, indeed. Apparently, there has been an ongoing problem with the Zend debugger not stopping at breakpoints on Mac Intel machines...something that has plagued Eclipse through 3 different PHP extensions. (don't even get me started on how crazy it is that Eclipse has seen three completely separate PHP plugins within less than a year)

In the end all was not lost. On the contrary, after enough scratching around Google I discovered what I needed to know. Komodo has become the semi-de-facto IDE of choice for many Drupal developers. A fact confirmed for me when I saw many familiar names from the Drupal community on the ActiveState website (itself a Drupal site).

Suffice to say with Komodo I got local and remote debugging up and running within just a couple hours, and it's been a total dream to use.

So now I have a proper debugger, integrated svn, and last but not least, Drupal api code compeletion/documentation is included. And if that's not enough, it uses 100mb+ less memory than Eclipse did.

Komodo is going to set me back a few bucks ($295) after my trial runs out, but even at that price it's a no-brainer for some who makes their living with Drupal and PHP. Kudos to ActiveState on their outreach to the Drupal community.

Some useful links if your interested in checking out Komodo:
Link 1
Link 2
Link 3
Link 4

13 September, 2007

High traffic: Serving 500,000+ unique visitors in 24 hours and over a 9,000,000 a month

Recently a client we helped get started with Drupal and admin their backend systems for, had their first 500,000+ unique-visitors day.

Everything went well, the lessons we've learned over the years of Drupal performance tuning (Part I, Part II), combined with well planned Apache/MySQL/PHP settings provided an event-free day (other than watching the hit counter go through the roof!).

Showing that it was no fluke, the site has had numerous 500,000+ days since then and has settled into an average of 150,000-200,000 unique views a day / 6,000,000-9,000,000 visitors a month.

If you have a Drupal site that you need to prepare for high traffic and high availability, give us a shout. We can help you handle it.

12 March, 2007
Subscribe to RSS - php