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

A better dd() for your TDD
Oct 13, 2016 @ 11:57:45

On the Tighten.co blog they have a recent post sharing a better dd() for your TDD - basically a better method for debugging the current state of object with a "dump and die" function.

An important part of every Laravel developer's debugging arsenal is the humble dd() helper function—"dump and die"—to output the contents of a variable and terminate execution of your code. In the browser, dd() results in a structured, easy-to-read tree, complete with little arrow buttons that can be clicked to expand or hide children of nested structures. In the terminal, however, it's a different story.

[...] Fortunately, it's simple to build your very own customized version of dd() to help tame your unwieldy terminal output—helping you find the details you're interested in quickly, without wearing out your trackpad (and your patience).

He provides two options you can use to help clean up the output of a "dump or die" method from the extensive results the current "dd" function provides:

Kint provides a few other helper methods you can use and easily configurable max and min depth to show in the output.

tagged: tdd testing vardumper kint library package output debugging

Link: https://blog.tighten.co/a-better-dd-for-your-tdd

Loïc Faugeron:
Mars Rover, Locating geolocation
Oct 05, 2016 @ 09:04:37

Loïc Faugeron is back with the next part of his "Mars Rover" series (you can find all of the articles so far here with his latest post covering the Locating class' geolocation functionality.

In this series we're building the software of a Mars Rover, according to the following specifications. It allows us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD)

We've already developed the first use case about landing the rover on mars, and the second one about driving it. We're now developing the last one, requesting its location. [...] In this article we're going to create a new package for the geolocation value objects (Location, Coordinates and Orientation).

He starts off by creating the geolocation package and its matching composer.json file. He then creates the phpspec configuration for the package and commits this initial version. He pulls this new package into the larger current codebase and makes an update to the overall phpspec configuration to run its tests. With that in place he updates two related packages, location and navigation, to include the new library before integration (coming in the next part of the series).

tagged: mars rover tutorial series location geolocation package

Link: https://gnugat.github.io/2016/10/05/mars-rover-locating-geolocation.html

Raphael Stolt:
Anatomy of a dope PHP package repository
Sep 22, 2016 @ 09:30:25

In this recent post to his site Raphael Stolt shares an example of what he thinks is a "dope" setup for a Composer package (a well-structured, consistent and fully populated package structure).

While contributing to Construct, maintained by Jonathan Torres, I gathered some insights and learnings on the characteristics of a dope PHP package repository. This post summarises and illustrates these, so that PHP package developers have a complementary guideline to improve existing or imminent package repositories. Jonathan Reinink did a good job in putting the PHP package checklist out there which provides an incomplete, but solid quality checklist for open-source PHP packages.

I'll distill the characteristics of a dope PHP package repository by looking at the repository artifacts Construct can generate for you when starting the development of a new PHP project or micro-package.

Included in his list of things every PHP package should include are things like:

  • the source (naturally), matching tests/specs and documentation
  • consistent naming
  • versioning information (via a CHANGELOG)
  • Travis-CI integration
  • A . gitattributes file for excluding certain files from export

He also makes a few more general suggestions like avoiding the posting of "badges" in the README and some reasons why you should care about the "dopeness" of your repository at all.

tagged: package wellstructured requirements opinion repository

Link: http://raphaelstolt.blogspot.com/2016/09/anatomy-of-dope-php-package-repository.html

Jason McCreary:
Update PHP on Mac OS X
Sep 20, 2016 @ 10:15:26

Jason McCreary has posted an update to his guide for installing PHP on Mac OS X and replacing the version of PHP that comes with El Capitan (5.5) with a handy package manager more specific to PHP installations.

As noted in my posts on Installing Apache, PHP and MySQL on Mac OS X, OS X comes pre-installed with Apache and PHP. Unfortunately, as of Mac OS X 10.11 (El Capitan) the pre-installed version of PHP is still 5.5. As PHP 5.5 has reached end of life, I imagine the pre-installed version of PHP will be updated with Mac OS 10.12 (Sierra). However, it may only be PHP 5.6.

So what do you do if you want to upgrade or install a different PHP version on your Mac? Well, you could use Homebrew. But I found a pre-packaged alternative - PHP OSX.

With this package manager, the installation is only a few steps but he lists them out with a bit more detail to help you understand what's happening:

  • Installing PHP (your choice of version)
  • Configuring Apache (loading the php5 shared module)
  • Updating your PATH
  • Configuring PHP
tagged: osx update language version package simple installation tutorial

Link: http://jason.pureconcepts.net/2016/09/upgrade-php-mac-os-x/

Freek Van der Herten:
Taking care of backups with Laravel
Sep 19, 2016 @ 09:34:13

Freek Van der Herten has posted a new article to his site covering the backup of your Laravel-based application with a handy package, laravel-backup. He's released a new major version so he wanted to catch you up on some of the features and functionality the package includes and how to use them for your application.

A new major version of laravel-backup was recently tagged. This package can backup files and databases of your Laravel app (or any PHP application really). The backup consists of a zipfile containing a dump of the databases and all files that are selected for backup. The package will copy over the zipfile to external storage such as S3, Dropbox, SFTP, … If something goes wrong during the package can notify you via, amongst others, mail or Slack. In this post I’d like to give some background on why and how it was built.

Keep in mind that there is no one size fits all solution for backups. A small company will probably handle backups in another way than a bigger company. This post has small companies in mind with a couple of developers and no dedicated operations person or team.

He starts off talking about "modern hosting" services and some of the issues that can come with them (downtime being one of the worst). He point out that providers like Linode and DigitalOcean only make periodic backups of your application and restoring from these could mean a lot of data loss - one of the worst things that can happen to an online business. With the laravel-backup package protecting against this kind of failure is easier, letting you automatically back up your site to an off-server source (like S3, Dropbox, or even another local location). He also describes the handling to clean up old backups, sending notifications when problems come up and simple monitoring functionality. He ends the post by mentioning once again that this package is designed for use with small-to-medium sized applications. Larger ones should work up a more robust, possibly external solution that doesn't rely on the application framework for its functionality.

tagged: backup laravel package laravelbackup tutorial downtime

Link: https://murze.be/2016/09/taking-care-of-backups-with-laravel/

Loïc Faugeron:
Mars Rover, Locating package
Sep 14, 2016 @ 09:51:52

Loïc Faugeron continues his long running series covering the creation of a "Mars Rover" package to help teach programming fundamentals. In this latest tutorial he starts on the last use case in the project: requesting the location of the "rover".

In this series we're building the software of a Mars Rover, according to the following specifications. It allows us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD). We've already developed the first use case about landing the rover on mars, and the second one about driving it. We're now going to start developing the last one, requesting its location:

Mars rover will be requested to give their current location (x and y coordinates and the orientation).

In this article we're going to create a new package for the location logic.

He starts by giving a justification as to why a new package is being created just for the location requests (when the navigation package could just be asked for that information). With that explained, he starts in on creating the new package and its tests with phpspec. He then adds this package into the current project's Composer configuration and updates the phpspec configuration to tell it about the newly creates code.

tagged: mars rover tutorial series location package phpspec

Link: https://gnugat.github.io/2016/09/14/mars-rover-locating-package.html

Laravel News:
Improved model generation with Laracademy Generators
Sep 08, 2016 @ 11:18:24

The Laravel News site has a quick tutorial posted showing you how using smarter generators to make model classes can help reduce your development time in Laravel applications (using a package to help adds the "smarts" needed).

Laravel provides the Artisan command line tool that allows you to save time by including several generators. Some examples include make:controller, make:model, and make:migration.

Building on top of this idea is a third party package named Laracademy Generators that will automatically generate your models based on your database structure.

They show first the normal process for creating a model and matching migration with the "artisan" command. Once this migration is run and the table is created, they can show how to automagically enhance the model with the generators package, using it to read from the table in the database and update the model with "fillable", "casts" and "dates" properties filled in.

tagged: model generator laracademy package improved database migration

Link: https://laravel-news.com/2016/09/improved-model-generation-with-laracademy-generators/

Laravel News:
How to Create A Most Popular List with Laravel and Google Analytics
Sep 02, 2016 @ 09:40:16

On the Laravel News site there's a new post showing you how to make use of the Google Analytics API in your Laravel application to find trending content in your site (most accessed pages).

Here on Laravel News, I wanted to generate a list of the most popular posts for the past seven days and display the results from most popular to least popular. To solve this problem I thought of two solutions. The first is to build my own tracking system so I could keep a count and then use it for ordering. However, that could generate a huge amount of data and it seemed like a solution that an analytics tracking service could handle.

As I was fumbling through the Google Analytics API I found a Laravel Analytics package by Spatie.be that allows you to easily retrieve data from your Google Analytics account and it seemed like the best way to solve this problem. Let’s look at how I used it to generate a list of popular posts here on Laravel News.

They then walk you through the installation (via Composer) and configuration of the library. This includes linking to more information about setting up the credentials for the connection. They then show how to use it to fetch the most popular pages and what the response looks like as a collection. Finally they show you how to create a wrapper class you can easily reuse anywhere in your application to fetch and display this "trending" information". The post ends showing you how to create a "View Composer" that only fires when the view is being rendered, not on every request.

tagged: laravel googleanalytics trending popular page results tutorial package

Link: https://laravel-news.com/2016/09/most-popular-list-laravel-google-analytics/

Freek Van der Herten:
Automatically generate a sitemap in Laravel
Sep 01, 2016 @ 10:51:31

Freek Van der Herten has a post to his site sharing a package and showing how to use it to generate a sitemap for your Laravel application automatically.

Today my company released a package called laravel-sitemap. There are already a lot of excellent sitemap packages out there. They all have in common that you have to manually add links that must appear in the sitemap. With our new package that isn’t required. It can automatically build up a sitemap by crawling a site. In this post I’d like to explain why we built it and how it works.

He starts off talking about why a sitemap might even be needed, mostly related to other automatic systems (like search engine spiders) that would use to reach even the far parts of your application. He then gets into the code, showing two examples of generating the XML document: one that's more manual and another using the "generator" to create based off of a base URL. He ends the post talking about some limitations of the package and includes a few links for further reading on the subject of sitemaps.

tagged: sitemap laravel application package example tutorial generate

Link: https://murze.be/2016/08/automatically-generate-a-sitemap-in-laravel/

Matthew Weier O'Phinney:
Using Composer to Autoload ZF Modules
Aug 18, 2016 @ 09:50:11

Matthew Weier O'Phinney has a new post to his site showing you how to can use Composer to autoload Zend Framework modules right along with the rest of the ZF components.

One aspect of Zend Framework 3, we paid particular focus on was leveraging the Composer ecosystem. We now provide a number of Composer plugins for handling things such as initial project installation, registering installed modules with the application, and more. It's the "more" I particularly want to talk about.

With ZF2, we were able to realize the ability to install third-party modules into existing applications, enabling a module ecosystem. [...] For the v3 release, we wanted to solve this if we could. We were able to do so via a Composer plugin, zend-component-installer.

This allows ZF module authors to add details into the "extra" section of their Composer configuration, making it so the plugin understands how to load the module automatically. They've also created a package to help do the same for Apigility applications and lets you remove any calls to "getAutoloaderConfig" in your modules.

tagged: zendframework autoload composer zf3 apigility configuration extra package

Link: https://mwop.net/blog/2016-08-17-zf-composer-autoloading.html