write the test case first (a simple PHP file checking if it's loaded and can be used)

updating the config.m4 to allow for enabling the extension

the code for src/hello.h to define the function

The final piece is the code in the src/hello.c - the C code to define some structure for the PHP interpreter to understand and be able to execute the PHP_FUNCTION(hello_world). Finally he shows how to make the extension to install it, add it to your php.ini file as a shared module and re-run the test.

On the Zaengle blog there's a post spotlighting the custom Blade directive functionality that comes with using the Blade templating engine of the Laravel framework. These allow the definition of custom functionality available directly from the templating layer.

Earlier today, I was working on coding up a design that displays a varying number of cards - each with a unique title and description… think Masonry/Pinterest-esque. I’ve been using Model Factories to stub out a bunch of cards, all with different content. Once I’d hooked up the dummy data to the card templates, I realized that the design didn’t work as well with titles that had more than 20 or so characters.

A common solution to this would be to use CSS to break the line and automatically add an ellipsis. [...] However, this wouldn’t work well in my situation because the design allows titles to be two lines long. Another solution would be to chop off the title at a given length and add an ellipsis using a php snippet. [...] However, adding this much PHP to my Blade templates would have really mucked up my otherwise-clean templates. So I decided to drop this functionality into a custom Blade directive that I could reuse where necessary.

He shows how to define the custom Blade directive in the AppServiceProvider class (autoloaded with every request) for a simple "Hello World" example. He also shows how to use this in the template code, making a simple call to its matching helloWorld tag. He then implements his custom truncate handling, returning some simple PHP code that automatically reduces the content down to a given length and echoes out the result.

Jared McFarland has a recent post to his site showing how to make a PHP extension in Rust, a more recent programming language that seeks to "run fast, prevent almost all crashes and eliminate data races".

Last October I had a discussion with one of my coworkers at Etsy about how writing extensions to interpreted languages like PHP, Ruby or Python should be a lot easier than it is now. We talked a bit about how one of the barriers to successfully writing an extension is they’re generally written in C, and it’s hard to gain confidence in C code if you’re not an expert at the language.

Ever since then I’ve toyed with the idea of writing one in Rust, and for the past few days have been playing around with it. I finally got it to work this morning.

He starts by static his goal, to make a PHP extension with Rust that was compiled into a library along with some C headers. He talks about his use of the Rust Foreign Function Interface to make a "hello world" script and the code to call it from C, complete with header code examples and the result of it being called. He then gets into the PHP integration, showing you the code you'll need for the extension and compiling it into a module and moving it into the extension directory. He also includes some "useless micro-benchmarks" so you can see how things perform, comparing his function to base PHP when calculating the Fibonacci sequence algorithm.

In the latest post to her site, Lorna Mitchell walks you through the creation of a first Phing plugin, an extension to the popular PHP-based build tool.

I'm a huge fan of Phing and use it regularly for build and deployment tasks. Often, I'll ask about a plugin that I wish existed, and get a very courteous "patches welcome" from the nice people in the #phing channel on freenode. This has happened a few times, so I thought I should probably look at how to make a new phing plugin, this article shows you how to make the simplest thing I could think of: a simple "hello world" plugin.

She points you to the location to grab the latest version of the tool (the github repository) and how to define a configuration file for your test runs. Then she includes the sample code showing how to create the "HelloTask" plugin. It takes an input value of "name" and displays a greeting when executed. She shows the syntax for defining this in the XML build file and the sample result when executed.

Over on Reddit.com there's a flamewar...er discussion happening about this set of benchmarks (from 2011) showing things like response time, system load average and a function execution map for several popular frameworks.

In the Reddit comments most people share the similar ideas about the results:

"I don't put much stock in hello world bench marks for MVCs. If you just need "Hello world" then write it in html."

"Asking which framework is the fastest is almost irrelevant in most cases. I always dislike benchmarks like this because the actual situation is so much more complicated than a handful of benchmarks can show."

"Any decent framework can output a simple content page from cache, it should not even have to call any router or controller. That's why simple content benchmarks are useless."

"Who cares? The speed of a language or framework does not translate over to the speed of your website. What matters is your architecture."

If you're looking for benchmarks that are more useful than these, I'd suggest checking out (and maybe contributing to) the ones Paul Jones has created over on Github.

On PHPMaster.com today there's a new tutorial posted about using the Phing build tool to automate a process, usually a build for a website launch. In his example, he shows a simple "Hello World" example and how to work with multiple targets in the same build file.

Phing is a PHP project build tool based on Apache Ant. A build system helps you to perform a group of actions using a single command. [...] Phing helps overcome [human error] issues by automating tasks like running unit tests, applying database changes, deploying application code, etc. In this article I’ll show you some of the basics of working with Phing.

He includes the commands you'll need to install Phing (if it's not already) via the PEAR installer and a basic "build.xml" file. He explains the parts of the file - tags for "project", "target" "echo" and "property - and includes a more complex build example with multiple targets (and how to call one specifically from the command line).

Dave Marshall is already looking ahead to the next major release of PHP, version 5.4, and one of the features it will include - traits. In this new post to his blog, he introduces a "logging trait" he's come up with to make logging simpler in your (Zend Framework) application.

One of the 'traits' I find myself constantly adding to library files is optional logging of it’s behaviour. The library class has it’s own log method, that checks to see if the instance has had a logger injected and if so, logs the message. I see this as a perfect candidate for becoming a reusable trait, as I tend to have the same code copy/pasted throughout my library classes. The problem is, according to the rfc, traits aren’t supposed to have state/properties, which makes it difficult to have a DI setter method in a trait.

He includes the code for his trait example (noting that it may or may not end up working correctly in the 5.4 final release) that sets a logger on a sample class and logs a few values out to the console. It's a simple example, but it shows you one of the most useful things about traits - the "drop in resuability" nature they allow in your libraries and classes.

For anyone wanting to take those first steps into running PHP applications on an Azure platform, you should check out a new post from Josh Holmes. He describes the process of getting it working from a command-line approach.

I thought we could kick it up a notch [from his previous post] and get PHP running in Azure leveraging the command line tools. The primary thing that we need to do is to copy the PHP bits up with the rest of your deployment and configure the FastCGI handler to know where the PHP interpreter can be found.

Once you get PHP installed testing it out is just a matter of getting his test page in the right directory, updating one of the configuration files (web.roleconfig), creating the Config/Definition files and packaging it all up with cspack. All of the contents for the sample configuration files and a screenshot of the fnal output are included.

New on the Zend Developer Zone is a tutorial showing a "Hello World" setup, configuration and testing of the Zend Core for the IBM i5 series from start to finish.

You've successfully installed the Zend Core for i5. Now what? The process of developing PHP scripts may not be obvious to System i developers familiar with RPG and COBOL. Let's take a look at the basic steps needed to start writing PHP scripts on System i.

They look at where the parts of the application are located, the steps to take to ensure it's running correctly, setting up Zend Studio and a personal development space and creating two simple scripts - one "Hello World" and the other that makes a DB2 connection to the local instance.

On the Adobe Developer Connection site Richard Bates has recently posted a tutorial covering the integration of PHP and Flex as developed in Zend Studio/Flex Builder.

Tight integration between Flex and a server-side language means that your users will have an intuitive, engaging user experience with all the functionality they need. For developers, tight integration between PHP and the Flex development environments can provide big benefits by ensuring a smoother workflow for coding, debugging, and managing a project. You can make the most of such a unified environment by using Adobe Flex Builder and Zend Studio for Eclipse together.

He starts with the basics - installing everything and getting it all up and running, then making a sample "Hello World" application on both the PHP (backend) and the Flex (frontend) sides. Included in the tutorial is a look at sending XML out to the Flex application from PHP.