"php" entries

Learning to Wait: Asynchronous Becomes Normal

Software grows patient

The biggest change I’ve seen in the last few years of software development isn’t a new language, a new environment, or magical new algorithms. The biggest change is that programmers in many different arenas, working independently, have come to accept waiting.

Part of the joy of computers, a magic that grew and grew as computers and networks got faster and faster, was the confidence that making a change was immediate. Yes, it took time to get a message over a network or for a CPU to execute calls—but things happened.

The event loop has been around for a long time—computers have always had to wait for us slow humans. Transactions have provided a buffer against the possibility of simultaneous changes to the same data, and certainly slowed things down, but the time that buffering took was generally considered a cost, not a feature. Message queues have existed for a long time, but again, seemed bulletproof but expensive.

Over the last few years, these approaches have become more common and better understood. I suspect that there are two main drivers of this change:

  • As larger scale projects have become more common, the knowledge needed to use these approaches has become more widely available. The average project may be larger scale as well, but these techniques are appearing even in cases where I wouldn’t have thought them necessary. (Of course, I also like playing with Erlang in tiny single-user environments.)

  • The Web always has latency, and JavaScript practice has evolved to support that. Asynchronous JavaScript may not be everyone’s dream work, but the pattern has evolved from UI events to Ajax to promises, deferreds, and much more. Node is built on these foundations. It’s not just JavaScript, though—I just found Asynchronous Processing with PHP on App Engine.

I saw a great talk last week on IndexedDB. It wasn’t the data storage or the asynchronous API that grabbed my attention, but the conversation about promises and ways to make “wait for it” seem like a normal programming idiom. There are a lot of those conversations happening now, about many environments.

Should we make asynchronous seem normal with syntax sugar? Or should we flag it, call attention to it, and make sure programmers remember that their code is waiting?

Asynchronous Processing with PHP on App Engine

OSCON 2013 Speaker Series

Note: Amy Unruh, Google Cloud Platform Developer Relations, is just one of the many fantastic speakers we have at OSCON this year. If you are interested in attending to check out Amy’s talk or the many other cool sessions, click over to the OSCON website where you can use the discount code OS13PROG to get 20% off your registration fee.

At this year’s Google I/O, we launched the PHP runtime for Google App Engine, part of the Google Cloud Platform. App Engine is a service that lets you build web apps using the same scalable infrastructure that powers many of Google’s own applications. With App Engine, there are no servers to maintain; you just upload your application, and it’s ready to go.

App Engine’s services support and simplify many aspects of app development. One of those services is Task Queues, which lets you easily add asynchronous background processing to your PHP app, and allows you to simultaneously make your applications more responsive, more reliable, and more scalable.

The App Engine Task Queue service allows your application to define tasks, add them to a queue, and then use the queue to process them asynchronously, in the background. App Engine automatically scales processing capacity to match your queue configuration and processing volume. You define a Task by specifying the application-specific URL of a handler for the task, along with (optionally) parameters or a payload for the task, and other settings, then add it to a Task Queue.
Read more…

5 Surprises for PHP Developers Coming to JavaScript

Unique features concealed within familiar syntax

PHP programmers often see the familiar C-like syntax of JavaScript and think it’s all flowers and roses. And while trivialities like loops and conditions are pretty much equivalent in both languages, things get very weird very quickly. Let’s take a look at the top 5 marvels JavaScript has to offer to the unsuspecting PHP veteran.

1. Functions are objects

Consider a function:

  function sum(a, b) {
    return a + b;
  }

It looks familiar, the only apparent difference being the missing $ to denote variables. But it turns out there’s more than that. The function sum() is actually an object. That means it can have properties and methods.

Something like:

 sum.length; // 2

… may come as a surprise. In this case length property of the sum object gives you the number of arguments this function expects.

And you’re not limited by built-in properties; you can assign any properties you like to the sum object. For example you can have a cache property that stores the results of previous (potentially expensive) calculations.

And since you can refer to functions just as regular variables, that means your function can take other functions as arguments (callbacks) and can also return functions as return values.
Read more…

eZ Publish: A CMS Framework with Open Source in Its DNA

Leading eZ Publish advocates look at what lies ahead for CMS programmers and users

ez-publish-1

There are a variety of options when it comes to content management. We’ve explored Drupal a bit, and in this email interview I talked to some folks who work with eZ Publish. It is an open source (with commercial options) CMS written in PHP. Brandon Chambers and Greg McAvoy-Jensen talk about how the platform acts as a content management framework, how being open source has affected the project, and what we should expect to see coming up for CMS in general.

Brandon Chambers is a Senior Developer at Granite Horizon, an eZ Publish integrator. He has 14 years of web development experience focused on open source technologies such as PHP, MySQL, Python, Java, Android, HTML, JavaScript, AJAX, CSS and XML.

Greg McAvoy-Jensen is a member of the eZ Publish Community Project Board. He also founded and is the CEO of Granite Horizon, and has been developing with eZ Publish since 2002.

Q: What problems does eZ Publish solve for users?

A: eZ Publish grew up not just as a CMS, but as a content management framework. It sports a flexible and object-oriented content model (an important early decision), and provides developers an MVC framework as a platform for building complex web applications and extending the CMS. Like any CMS it makes content publishing accessible for the non-programmer, and provides an easy editorial interface. eZ Publish does a fine job of separating content from presentation and providing reusability and multi-channel delivery. It targets the enterprise more than smaller organizations, so the software quality remains pegged at high standards, and high degrees of flexibility and extensibility continue to be required.

Q: How you feel being open source has affected the project?

A: Fourteen years on, eZ Systems is still firm that open source is in its DNA. This foundational commitment created a culture of sharing, and it attracts developers who prefer to share their code and to collaborate with others outside their organization for the benefit of their customers. Contributions flow in as both extensions and core code pull requests. The commercial open source model, similar to Red Hat’s, means the vendor takes primary responsibility for code maintenance and development, and derives its profit from support subscriptions, while leaving customizations to its network of certified partners. Because the source is open, organizations evaluating the software can have their developers compare the code of, for example, eZ Publish and Drupal, and make their own determinations. This, in turn, keeps the vendor accountable for the code: eZ engineers program knowing full well that the world can see their work.

Q: What distinguishes eZ Publish from other CMS options?

A: While there may be a thousand or so CMS’s around, analysts typically look at something more like 30 that are important today. eZ Publish fits into that group, most recently by inclusion on Gartner’s Magic Quadrant beginning in 2011. Not all open source CMS’s have a vendor behind them who both provides support and has full control over the code, a level of accountability required in enterprise applications. eZ is a great fit for particularly complex implementations, or situations where there is no assurance that future needs will be simple. And despite the complex customizations developers do with eZ Publish, they rarely interfere with upgrades.

eZ’s engineers recently became dissatisfied with the merely vast degree of flexibility they had built into the MVC framework, so they’ve now moved the whole system on top of the Symfony PHP framework. eZ Publish is now a native Symfony application, the only CMS to utilize Symfony’s full stack. This leverages the great speed and excellent libraries Symfony provides, and makes eZ easier to learn by those who are familiar with Symfony. Some CMS’s require many plug-ins just to get a basic feature set going on a site, but eZ Publish has long included granular security, content versioning, multi-language support, multi-channel/multi-site capability, workflows, and the like as part of the kernel.
Read more…

Drupal for Designers

Dani Nordin on what you need to know

Dani Nordin (@danigrrl) is an O’Reilly author (Drupal for Designers) and UX designer.

We sat down recently to catch up on her current projects and her predictions for the future of Drupal design. She shared some best practices for designing, her experiences with a large-scale academic project, and what criteria goes into the Design 4 Drupal Boston event.

Highlights from the conversation include:

  • Learn the common pitfalls Drupal designers fall into, along with some tips and tricks to avoid them (hint: Drupal is like a cake recipe) [Discussed at the 0:17 mark].
  • How the Berklee College of Music is using Drupal [Discussed at the 5:49 mark].
  • The focus for 2013’s Design 4 Drupal Boston [Discussed at the 7:50 mark].
  • The ways Drupal 8 could change how designers work [Discussed at the 9:40 mark].

You can view the entire interview in the following video.

Read more…

How you can stop trashing PHP code

Design patterns for PHP

William Sanders (@williebegoode) is a Professor of Interactive Information Technology at the University of Hartford and author of over 40 technical books! His latest book with us is Learning PHP Design Patterns. We recently sat down to talk about design patterns and how they can help create reusable code and save you valuable time. You can also check out more from Bill at his website.

  • Why use design patterns for PHP? [Discussed at the 0:28 mark.]
  • Big programs and lots of code can become unwieldy [Discussed at the 2:06 mark.]
  • Mobile devices and PHP design patterns [Discussed at the 5:30 mark.]
  • Bill talks common design patterns and how they help [Discussed at the 7:25 mark.]
  • How to start using design patterns with PHP [Discussed at the 10:15 mark.]

You can view the entire interview in the following video:

Related:

The key web technologies that work together for dynamic web sites

An interview with the author of Learning PHP, MySQL, JavaScript, and CSS

The technologies that led to an explosion of interactive web sites — PHP, MySQL, JavaScript, and CSS — are still as popular today, and a non-programmer can master them quickly.

Developer Week in Review: Java on trial

The trial of the century continues, cat feeders and coding, and PHP sites at risk.

Google and Oracle continue to duke it out in court, with more than just Android at risk. One developer uses cat feeders as a way to look at good software, and the PHP developers take a second try at fixing a critical bug.

Four short links: 14 December 2011

Four short links: 14 December 2011

PHP Virtual Machine, Archive Your Tweets Easily, Prioritize Your Links, VC Memes

  1. The HipHop Virtual Machine (Facebook) — inside the new virtual machine for PHP from Facebook.
  2. PHP Fog’s Free Thinkup Hosting (Expert Labs) — ThinkUp archives your tweets and other social media activity for you to search, visualize, and analyze. PHPFog hosts PHP apps scalably, and I’m delighted to be an advisor. Andy’s made a video showing how to get up and running with ThinkUp in 3m. (This is impressive given how long I squinted at ThinkUp and swore trying to get it going on my colo box just a year ago)
  3. The Secret Lives of Links (Luke Wroblewski) — notes on a talk by Jared Spool. On the Walgreen’s site, 21% of people go to photos, 16% go to search, 11% go to prescriptions, 6% go to pharmacy link, 5% go to find stores. Total traffic is 59% for these five links. The total amount of page used for these 5 links is ~4% of page space. The most important stuff on the page occupies less than 1/20th of the page. This violates Fitts’s Law. Makes me think of the motor and sensory homunculi.
  4. VC Memes — the success kid is my favourite, I think.
Four short links: 19 April 2011

Four short links: 19 April 2011

Elegant Boxes, Dashboard in PHP, Management Theory Disparaged, and Obsolete Technology

  1. Lines (Mark Jason Dominus) — If you wanted to hear more about phylogeny, Java programming, or tree algorithms, you are about to be disappointed. The subject of my article today is those fat black lines. Anatomy of a clever piece of everyday programming. There is no part of this program of which I am proud. Rather, I am proud of the thing as a whole. It did the job I needed, and it did it by 5 PM. Larry Wall once said that “a Perl script is correct if it’s halfway readable and gets the job done before your boss fires you.” Thank you, Larry.
  2. PHP Clone of Panic Status Board (GitHub) — The Panic status board shows state of downloads, servers, countdown, etc. It’s a dashboard for the company. This PHP implementation lets you build your own. (via Hacker News)
  3. The Management Myth (The Atlantic) — a philosophy PhD gets an MBA, works as management consultant, then calls bullshit on the whole thing. Taylorism, like much of management theory to come, is at its core a collection of quasi-religious dicta on the virtue of being good at what you do, ensconced in a protective bubble of parables (otherwise known as case studies). (via BoingBoing)
  4. Obsolete Technology — or, as I like to think of it, post-Zombie-apocalypse technology. Bone up on your kilns if you want your earthen cookware once our undead overlords are running (or, at least, lurching) the country. (via Bruce Sterling)