Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DeliciousBrains.com:
Hooks, Line, and Sinker: WordPress’ New WP_Hook Class
Jan 25, 2017 @ 16:34:02

The Delicious Brains site has a new post looking at an addition to the WordPress platform allowing you to hook into the core - the WP_Hook class. In the latest release of WordPress this system received a major overhaul and in this article they share what's been updated and what kind of impact it should have on your code.

The hooks system is a central pillar of WordPress and with the 4.7 release a major overhaul of how it works was merged. The Trac ticket that initially raised an issue with the hooks system was logged over 6 years ago. After a few attempts, the updates finally made it into the 4.7 release and the venerable hooks system was overhauled. In this post I want to go over some of the technical changes and decisions that went into the new WP_Hook class. I’ll also go over some of the more interesting aspects of WordPress core development and look into what it takes to overhaul a major feature in WordPress core.

The post starts out with what's changed related to the hooks handling, mostly that the functionality has moved out into a new "WP_Hook" class. This migrates it way from being handled right next to the plugin logic. He details some of the behind the scenes changes to the code and changes made to help improve performance. The post finishes out looking at the backwards compatibility of these changes and what it means for developers upgrading to this new WordPress version (hint: not much).

tagged: tutorial wordpress hooks upgrade class improvement performance

Link: https://deliciousbrains.com/hooks-line-sinker-wordpress-wp-hook-class/

Cees-Jan Kiewiet:
Run GrumPHP git hooks within Vagrant
Jun 07, 2016 @ 17:22:11

Cees-Jan Kiewiet has a post on his site showing you how to run GrumPHP hooks in Vagrant, a tool that allows for code quality evaluation.

A couple of weeks back while attending AmsterdamPHP Mike Chernev gave a talk about GrumPHP. Very cool looking tool, but during implementation I found out it the default setup assumes running grumphp on the same machine (whether that is a VM or iron) as committing. That is a problem in my set up where all PHP related code runs in vagrant and comitting on the host using PHPStorm. Lets fix that.

The post includes the scripts you'll need to include in your Vagrant setup to execute the quality checks on commit, pre-commit and the Vagrant hook setup to run everything inside of the VM instead of locally.

tagged: grumphp hooks git vagrant commit

Link: https://blog.wyrihaximus.net/2016/06/run-grumphp-git-hooks-within-vagrant/

SitePoint PHP Blog:
Drupal 8 Hooks and the Symfony Event Dispatcher
Oct 21, 2014 @ 18:14:53

The SitePoint PHP blog has a new tutorial posted today showing the interaction between Drupal 8 hooks and the Symfony dispatcher in the last part of their series showing how to build a custom Drupal 8 module.

With the incorporation of many Symfony components into Drupal in its 8th version, we are seeing a shift away from many Drupalisms towards more modern PHP architectural decisions. For example, the both loved and hated hook system is getting slowly replaced. Plugins and annotations are taking away much of the need for info hooks and the Symfony Event Dispatcher component is replacing some of the invoked hooks. Although they remain strong in Drupal 8, it’s very possible that with Drupal 9 (or maybe 10) hooks will be completely removed.

He starts off with a brief introduction to what the event dispatcher is and how it currently interacts with the Drupal 8 system. He uses a simple form example with two text fields and how to hook in the dispatcher to fire a "demo_form.save" event when the user submits the form. He ties this into a DemoEvent and sets up a simple subscriber. He ends the article with a look at using hooks to achieve the same kind of goal.

tagged: drupal8 tutorial hooks event dispatcher symfony component

Link: http://www.sitepoint.com/drupal-8-hooks-symfony-event-dispatcher/

Till Klampaeckel:
Speeding up composer on AWS OpsWorks
Oct 09, 2013 @ 17:10:25

Till Klampaeckel has a new post today showing how to get your Composer installation (and package install) to work a bit faster on the Amazon AWS OpsWorks management system.

At EasyBib, we're heavy users of composer and AWS OpsWorks. Since we recently moved a lot of our applications to a continuous deployment model, the benefits of speeding up the deployment process (~4-5 minutes) became more obvious.

He talks some about the current needs of their deployment process and how one option - symlinking the "vendors" directory just wouldn't work. Instead, they make use of Ruby and Chef to work with the OpsWorks hook system that fire on deployment. He includes the example Ruby scripts they put in place to handle "before migrate", "before symlink", "before restart" and "after restart" events. This new setup saved them about two to three minutes on their total deployment time and resulted in a much more stable environment.

tagged: amazon aws opsworks composer install ruby chef hooks deployment

Link: http://till.klampaeckel.de/blog/archives/202-Speeding-up-composer-on-AWS-OpsWorks.html

SitePoint PHP Blog:
Git Hooks for Fun and Profit
Sep 25, 2013 @ 17:45:21

If you're a git user (you do use git, right?), there's a powerful feature that can help perform some automatic actions in your repositories - git hooks. In this new post to the SitePoint PHP blog, Timothy Boronczyk introduces you to them and how to set them up.

When certain commands are run, Git searches the .git/hooks directory for suitable hook scripts which are then executed if found. You’ll find a small set of example scripts there (you can activate them by renaming them to remove the .sample prefix and setting their executable bit), and a complete list of hooks can be found in the githooks(5) man page. This article suggests a handful of hooks which can streamline development and help improve your efficiency.

He gives four different examples of checks based on the state of the commit (like pre-commit or post-commit):

  • Lint Checks
  • Spell-Check Commit Messages
  • Checking Standards
  • Automatically Run Composer

Each comes with the example code needed to implement them and some description about what they're doing.

tagged: git hooks introduction example lint spelling standards composer

Link: http://www.sitepoint.com/git-hooks-fun-profit

NetTuts.com:
Setting Up A Staging Environment
Feb 15, 2013 @ 16:49:39

On NetTuts.com today Gabriel Manricks walks you through setting up a staging environment using Vagrant to install and setup a virtual machine running Apache 2 and PHP 5.4.

Creating a staging environment is specific to your production environment. There is no magic solution that works in every situation. But most cases follow a similar pattern, and I’ll cover all the key points as we go along. It’s fair to assume that most people deploy their apps with some kind of versioning tool (like GIT). [...] Besides GIT, you have to think about the languages, software, and “special” features your production servers offer.

All of the commands and configuration files you'll need to make the automatic setup work are included in the article. It's based on a Debian (Squeeze) base image and uses packages to install the needed software. They also install other PHP extensions like mycrypt, GD, curl, APC and database support (MySQL, SQLite and Postgres). They help you get Apache set up to serve the application and work with git and its hooks to push the code and run Composer.

tagged: staging environment tutorial vagrant git apache deployment hooks

Link:

Diniki.net:
PHP Design Patterns
Jul 25, 2006 @ 11:08:07

Patterns in PHP are becoming more and more popular, and sites like this one are doing well to provide summaries of each with code examples to help clarify.

Following my petty wingeing about the design patterns in php on the web I have to bite the bullet and do something about it. So here it comes a collection of design pattern examples, some from the GOF book, some collected from around the net, some (maybe) I have discovered.

The intent of these pages is to show the shapes of the patterns not a fully fledged implementation. In real life probably a combination of patterns will be employed. Everyone has their own favourites following their political, religious and style differences.

He admits that the pages are a work in progress and aren't complete, but they're a start to share his studies with the world. His list of patterns so far includes:

with more to come. All of his examples under each pattern are written in PHP.

tagged: design patterns listing control abstraction hooks facade observer design patterns listing control abstraction hooks facade observer

Link:

Diniki.net:
PHP Design Patterns
Jul 25, 2006 @ 11:08:07

Patterns in PHP are becoming more and more popular, and sites like this one are doing well to provide summaries of each with code examples to help clarify.

Following my petty wingeing about the design patterns in php on the web I have to bite the bullet and do something about it. So here it comes a collection of design pattern examples, some from the GOF book, some collected from around the net, some (maybe) I have discovered.

The intent of these pages is to show the shapes of the patterns not a fully fledged implementation. In real life probably a combination of patterns will be employed. Everyone has their own favourites following their political, religious and style differences.

He admits that the pages are a work in progress and aren't complete, but they're a start to share his studies with the world. His list of patterns so far includes:

with more to come. All of his examples under each pattern are written in PHP.

tagged: design patterns listing control abstraction hooks facade observer design patterns listing control abstraction hooks facade observer

Link:


Trending Topics: