Disabling PHP 5.5.3 OPcache in MAMP

A student in my MCAD PHP and WordPress class ran into a curious issue where her changes to PHP scripts running in MAMP weren’t reflected when she refreshed the page in a browser, unless she opened the page in a new tab. Turns out OPcache is enabled by default in PHP 5.5.3 running in MAMP 2.2. Here’s a Stack Overflow post on how to disable it in your php.ini file.

The steps:

  1. Find your php.ini file. In my MAMP installation it was located at: /Applications/MAMP/bin/php/php5.5.3/conf/php.ini.
  2. Comment out the OPcache lines at the bottom by putting a semicolon in front:
    [OPcache]
    ;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
    ;  opcache.memory_consumption=128
    ;  opcache.interned_strings_buffer=8
    ;  opcache.max_accelerated_files=4000
    ;  opcache.revalidate_freq=60
    ;  opcache.fast_shutdown=1
    ;  opcache.enable_cli=1
    
  3. Stop and start your MAMP servers.

Overriding Drupal 7 Field Collection Templates

Occasionally you’ll want to theme a field collection. I’ve done this in the past at the node template level, by walking through the content array and pulling the field collection item, then looping through to find the child that has a numeric index. Pretty convoluted:

<?php
    foreach($content['field_image_item'] as $key=>$field_collection) {
    if(is_numeric($key) && !empty($field_collection['entity']['field_collection_item'])) {
      $field_image_item = current($field_collection['entity']['field_collection_item']);
        print '<li>';
        print '<div class="img">';
        print render($field_image_item['field_image_asset']);
        print '</div>';
        print '<div class="flex-caption">' . render($field_image_item['field_image_caption']) . '</div>';
        print '</li>';
    }
  }
?>

And—as it turns out—completely unnecessary in most cases, because you can override a field collection item by simply creating a template file with the name field-collection-item--field-[fieldname].tpl.php. So, for the example above I could have just created a template named field-collection-item--field-image-item.tpl.php. You can use the template file field-collection-item.tpl.php in the field_collection module folder as a starting point.

So at the node template level you could just render the field:

<?php print render($content[field_image_item’]); ?>

and in the new template you have direct access to the child fields without needing to test for a numeric index:

<li>
<div class="img">
    <?php print render($field_image_item['field_image_asset']); ?>
</div>
<div class="flex-caption">
    <?php print render($field_image_item['field_image_caption']); ?>
</div>
</li>

Many thanks to my colleague Putra Roeung for the tip.

Holding Amelia

My niece Hannah was born this past Sunday night, which gave me one more reason to finish this post. I find myself writing more and more frequently about fatherhood these days, perhaps subconsciously fighting against the fading memory of these moments. Here’s a few notes I wrote the morning I first held my daughter Amelia in my arms:

  • She was kinda gray at first.
  • She was smaller and lighter than I had expected.
  • Her skin was impossibly soft.
  • She tried to wiggle her left hand out of any swaddle.
  • I didn’t feel nervous holding her, unlike when I held my friends’ babies.
  • I thanked God that she was healthy.

Fathers often speak of that first moment in very sentimental terms, insisting that their baby’s arrival suddenly changed them to the core—all of these buried secrets of fatherhood unlocked in an instant. I do think there is a profound moment there, but I’m a bit wary of ascribing too much significance to it. I think it’s often too easy to focus on the beginnings of things, and gloss over the winding paths that follow.

Those paths are often quite prosaic, and so for me that moment probably falls closer to a signal, a harbinger of the (possible) slow change that marks the majority of parenthood. I choose not to read it as immediate transformation so much as a whisper that change was coming. Like my heart was creaking open just the tiniest bit.

Holding Amelia for the first time, I was not magically changed into a good man, but I could imagine what that man would be like. More importantly, I wanted to become that man. I recall a distinct sense of relief, that finally here was something of indisputable worth to which I could devote my time and attention. I caught a glimpse of the possibility of escape from the tyranny of self.

That rush of emotion you feel when you first hold your child quickly gets subsumed under a million other things, and if you’re not careful you can forget your better self calling to you. There’s a window of time, there—when your heart is wide open and you’re brimming with joy—and in that space you can start to see a life that isn’t centered around your own selfish desires. You can imagine willingly letting your own dreams die to see a bigger, more worthy one take flight.

We talk almost universally about simply knowing in that moment that we would sacrifice our very lives for our children. But to me, the more intriguing idea that follows is this: if we would lay down our lives for our children, could we also be willing to do so for our friends? And beyond our friends, the world at large? I hope that the world could simultaneously contract and expand for a new parent: you hunker down, changed almost imperceptibly by a series of small tasks. Wake. Shush. Pat. Feed. Change nappies. You respond with love to a creature who embodies guileless selfishness, which (to borrow a phrase from my pastor) paradoxically burns the selfishness out of you. Meanwhile, your soul expands, pushing uncomfortably at the bounds that have slowly trapped it over time.