22 Oct 2017

feedPlanet PHP

Short and safe array iteration

Short and safe array iteration

Submitted by Larry on 22 October 2017 - 5:50am

One reason to follow development mailing lists is you sometimes pick up on some very neat tricks. Here's one that I spotted on the PHP Internals list recently to simplify array iteration in PHP 7.

22 Oct 2017 9:50am GMT

20 Oct 2017

feedPlanet PHP

The 3 paragraph pitch

The 3 paragraph pitch

Earlier this week a fellow PHP public figure tweeted saying that I write great session proposals for conferences. After I finished blushing I reached out to him and we talked a bit about what it was he likes about them. (Whatever I'm doing right, I want to know to keep doing it!)

Based on that, I figured it would be educational to dissect how I go about writing session proposals for conferences and hope that conference organizers don't catch on to my tricks. :-)

Larry 20 October 2017 - 6:21pm

20 Oct 2017 10:21pm GMT

Interview with Alan Seiden

alanseiden Audio Show Notes ZendCon 2017 talk - PHP AND DB2 IN DEPTH ZendCon 2017 talk - BRING RPG/COBOL BUSINESS LOGIC TO THE WEB WITH THE PHP TOOLKIT ZendCon 2017 talk - MAKE YOUR IBM I SIZZLE WITH WORDPRESS ZendCon 2017

The post Interview with Alan Seiden appeared first on Voices of the ElePHPant.

20 Oct 2017 11:30am GMT

Building a CI System with Free Tools and Duct Tape

January 2018 - EU
Presented By

Julian Egelstaff
January 18, 2018
20:00 CET

The post Building a CI System with Free Tools and Duct Tape appeared first on Nomad PHP.

20 Oct 2017 4:05am GMT

18 Oct 2017

feedPlanet PHP

Git and WordPress: How to Auto-Update Posts with Pull Requests

At Bitfalls.com, we also use WordPress for now, and use the same peer review approach for content as we do at SitePoint.

We decided to build a tool which automatically pulls content from merged pull requests into articles, giving us the ability to fix typos and update posts from Github, and see the changes reflected on the live site. This tutorial will walk you through the creation of this tool, so you can start using it for your own WordPress site, or build your own version.

The Plan

The first part is identifying the problem and the situation surrounding it.

The solution is the following:


If you'd like to follow along (highly recommended), please boot up a good virtual machine environment, install the newest version of WordPress on it, and add the WPGlobus plugin. Alternatively, you can use a prepared WordPress box like VVV. Additionally, make sure your environment has ngrok installed - we'll use that to pipe Github hook triggers to our local machine, so we can test locally instead of having to deploy.


For this experiment, let's create a new repository. I'll call mine autopush.

In the settings of this repository, we need to add a new hook. Since we're talking about a temporary Ngrok URL, let's first spin that up. In my case, entering the following on the host machine does the trick:

ngrok http homestead.app:80

I was given the link http://03672a64.ngrok.io, so that's what goes into the webhook, with an arbitrary suffix like githook. We only need push events. The json data type is cleaner, so that's selected as a preference, and the final webhook setup looks something like this:

Webhook setup

Let's test this now.

git clone https://github.com/swader/autopush
cd autopush
touch README.md
echo "This is a README file" >> README.md
git add -A
git commit -am "We're pushing for the first time"
git push origin master

The ngrok log screen should display something like this:

POST /githook/                  404 Not Found

This is fine. We haven't made the /githook endpoint yet.

Processing Webhooks

We'll read this new data into WordPress with custom logic. Due to the spaghetti-code nature of WP itself, it's easier to circumvent it entirely with a small custom application. First, we'll create the githook folder in the WordPress project's root, and an index.php file inside it. This makes the /githook/ path accessible, and the hook will no longer return 404, but 200 OK.

According to the docs, the payload will have a commits field with a modified field in each commit. Since we're only looking to update posts, not schedule them or delete them - those steps are still manual, for safety - we'll only be paying attention to that one. Let's see if we can catch it on a test push.

First, we'll save our request data to a text file, for debugging purposes. We can do this by modifying our githook/index.php file:

file_put_contents('test.txt', fil

Truncated by Planet PHP, read more at the original (another 1035 bytes)

18 Oct 2017 9:54pm GMT

Interview with Colin O’Dell

colinodell Audio Show Notes ZendCon 2017 talk - COMMONMARK - MARKDOWN DONE RIGHT ZendCon 2017 talk -RISE OF THE MACHINES: PHP AND IOT ZendCon 2017 AlexaApp PHP Alexa Helpers

The post Interview with Colin O'Dell appeared first on Voices of the ElePHPant.

18 Oct 2017 11:30am GMT

Displaying errors in Expressive with Twig

If you're not using the Whoops error handler with Expressive and are using the Twig renderer, then you are given no information about the problem that occurred, even in debug mode. To fix this, I changed error.html.twig to this: [crayon-59eaf9f4d2144248344112/] The new part is the within the {% if error %} block. In debug mode, error is set to the exception that was thown and is blank otherwise, so you won't leak sensitive information (as… continue reading.

18 Oct 2017 10:03am GMT

17 Oct 2017

feedPlanet PHP

Choose Dependency Injection — If You Can

Some people say, "You don't need to use dependency injection for everything. Sometimes dependency injection is not the best choice." It occurs to me that the people who say this are the ones who can't use it for everything. They say "choose what's best for your situation", but their situation precludes the use of dependency … Continue reading Choose Dependency Injection - If You Can

17 Oct 2017 2:00pm GMT

Atlas.Orm 2.0 Is Now Stable

I am very happy to announce that Atlas, a data-mapper for your persistence layer in PHP, is now stable for production use! There are no changes, other than documentation updates, since the beta release two weeks ago. You can get Atlas from Packagist via Composer by adding … "require": { "atlas/orm": "~2.0" } … to … Continue reading Atlas.Orm 2.0 Is Now Stable

17 Oct 2017 1:43pm GMT

16 Oct 2017

feedPlanet PHP

Interview with Adam Culp

adamculp Audio Show Notes ZendCon 2017 talk - DEBUGGING ELEPHPANTS ZendCon 2017 talk - PRACTICAL PHP DEPLOYMENT WITH JENKINS ZendCon 2017

The post Interview with Adam Culp appeared first on Voices of the ElePHPant.

16 Oct 2017 11:30am GMT