Medium.com: Generating Code Coverage with PHPUnit and phpdbg

In this post on his Medium page Elton Minetto shows how to generate the code coverage of your PHPunit tests with better performance using phpdbg.

In a previous post (in portuguese) I explained how to identify tests that are taking too long to execute. In this post, I’ll show you how to increase the performance of code coverage report generation using PHPUnit.

In the phpunit.xml file it’s possible to add configurations to generate reports related to the tests that are being executed. […] In addition to changing the phpunit.xml file, to generate this information we also need to install the extension XDebug. However, by installing it we get a substantial decrease in performance.

He shows an example of the time difference in running the tests (about 1 minute without versus 22 with XDebug). He went looking for a better way and found this post talking about using phpdbg instead. He includes the "brew" commands to get everything you’ll need installed and how to use phpdbg with your coverage calls rather than XDebug. However, as is pointed out at the end of the post, the results are slightly different but they’re close enough to help you know what code to target next.

PHPDeveloper.org

php[architect]: September 2016 Issue Released – Legacy Code of the Ancients

php[architect] magazine has officially announced the release of their September 2016 issue: Legacy Code of the Ancients.

We don’t always have the luxury of working on greenfield projects where we can try out the latest language features, component libraries, or programming techniques. More often, we’re asked to take care of and add features to an application that just works and supports a company or organization’s objectives—like making money to pay salaries. Unless it’s a relatively new project, you are sure to run into corners of the codebase that should be modernized. The trick is to find the time and marshal your team to do so.

Articles in this month’s edition include:

  • "Illuminating Legacy Applications" (Colin DeCarlo)
  • "Legacy Code Needs Love Too" (John Congdon)
  • "Building for the Internet of Things in PHP" (Adam Englander)

The usual columns are there as well including the "Education Station" and "Security Corner". You can pick up your own copy of this month’s issue directly from the php[architect] site. If you just want a sample of the content, check out this month’s free article – "The Modernization of Multiple Legacy Websites".

PHPDeveloper.org

PHPUgly Podcast: Episode 24 – The Value of Work

The PHPUgly podcast has posted their latest episode as recorded on August 18th, 2016 – Episode #24. Join hosts Eric Van Johnson and Tom Rideout as they talk about:

  • The TV show "Mr Robot"
  • the SDPHP and SDLUG Meetups
  • the "FIG Follies" articles
  • the idea of "Being asked to work for free"

You can listen to this latest episode either using the in-page audio player or over on SoundCloud. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter for updates on when the latest shows are released.

PHPDeveloper.org

Alex Bowers: Writing a Hello World PHP 7 Extension

In a recent post to his site Alex Bowers shows you the steps involved in creating a "Hello World" PHP 7 extension with some basic output functionality – basically just echoing out a message.

He jumps right into the code and shows you how to:

  • set up the directory and initial files for the extension
  • 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.

PHPDeveloper.org

SitePoint PHP Blog: Sculpin Extended: Customizing Your Static Site Blog

The SitePoint PHP blog has a new tutorial posted helping those Sculpin users out there get the most from their site with some helpful customization tips. Sculpin is a PHP-based static site generation tool that converts Mardon files and Twig templates into HTML documents ready for use.

If you’re a PHP developer and currently running a blog with a static site generator such as Octopress or Jekyll, wouldn’t it be great if you could use your primary language for it? Yes, it’s healthy for us developers to use more than one language, but let’s be honest – we often want to add some functionality to our blogs, but it’s difficult to accomplish in unfamiliar syntax. In this article, we’ll set up Sculpin, a static site generator for PHP. Just like any other static site generator, it uses markdown files and HTML templates to generate your blog, so the transition should be easy.

The tutorial starts by helping you get Sculpin installed (as a phar executable) and move it to where it’s globally accessible. With that installed the article then helps you make a simple blog, customize some of the basic settings and start in on a new blog post. With that in place it then gets into the customization, adding in:

  • syntax highlighting
  • Disqus commenting
  • blog archive links

The post finishes up showing you how to deploy the resulting blog into a GitHub pages repository and pushing them out for public consumption.

PHPDeveloper.org

Laravel News: How to use WordPress as a backend for a Laravel Application

The Laravel News site has posted an interesting tutorial where they describe the use of WordPress as a backend for a Laravel application. This setup is based on the Laravel News‘ own experience with it in the recent refactoring of the site.

Last week I relaunched Laravel News, and the new site is running on Laravel with WordPress as the backend. I’ve been using WordPress for the past two years, and I’ve grown to enjoy the features that it provides. The publishing experience, the media manager, the mobile app, and Jetpack for tracking stats.

I wasn’t ready to give these features up, and I didn’t have the time to build my own system, so I decided to keep WordPress and just use an API plugin to pull all the content I needed out, then store it in my Laravel application. In this tutorial, I wanted to outline how I set it all up.

While he did find other methods for linking the two, they didn’t quite fit with what he wanted so he worked up his own. The content is then synced via a recurring task pulling over posts, categories and tags. He gets into the WordPress REST API first, showing the extraction of the posts from the API and pushing them into a Laravel collection. There’s also an example of how to sync a post with the database (API) and how to create a new post in a similar way. Also included is the code to get the featured image, get the category for a post and sync the tag values. The tutorial finishes with the code for the sync command and pushing it into the scheduler.

PHPDeveloper.org

IBM Developer Blog: Get Started With CouchDB Using PHP and Guzzle

On the IBM Developer Blog they’ve posted a new article from Lorna Mitchell helping you get started with CouchDB and Guzzle, making use of this popular HTTP client package to interface with CouchDB’s HTTP interface quickly and easily.

In today’s post, we’ll look at how we can use CouchDB in our PHP applications, using the excellent PHP HTTP library Guzzle. Guzzle is a modern, PSR-7 compliant object-oriented PHP library that handles all aspects of HTTP in a correct and — importantly, a scalable — way. So it’s a great way to add any HTTP-interfaced services into your application (PHP 5.5 and later, does support PHP 7).

She then starts off with the installation of Guzzle via Composer and some sample code to make the initial connection to the CouchDB server (either local or remote). With the connection up and working and a "welcome" banner returned, she shows some simple operations like:

  • getting a list of all databases
  • creating a new database
  • inserting and selecting data
  • updating and deleting data

Code is provided for each of these and, thankfully, Guzzle makes it a pretty simple process and handles most of the heavy lifting on the HTTP requests for you.

PHPDeveloper.org

PHP.net: PHP 5.6.24 & 5.5.38 Released

The PHP development group has posted the official release announcements for the latest versions in the PHP 5.6.x and 5.5.x series: PHP 5.6.24 and PHP 5.5.38.

The PHP development team announces the immediate availability of PHP [5.6.24 and 5.6.38]. This is a security release. Several security bugs were fixed in this release. All PHP 5.6 users are encouraged to upgrade to this version.

They also have a quick note that this release for the PHP 5.5.x series is the last in the branch as laid out by the release schedule. Future updates on this branch will only be made if there are major security issues found. Otherwise developers are encouraged to upgrade to the latest versions (5.6.x at the least but really PHP 7.x would be better). You can get these latest releases either from the main downloads page (source) or from windows.php.net for the Windows binaries.

PHPDeveloper.org

Site News: Blast from the Past – One Year Ago in PHP (07.21.2016)

Here’s what was popular in the PHP community one year ago today:

  • Easy Laravel Book: How Laravel 5 Prevents SQL Injection, CSRF, and XSS
  • Barry vd. Heuvel: OAuth in Javascript Apps with Angular and Lumen, using Satellizer and Laravel Soci
  • Remi Collet: New „remi-php70“ repository
  • Simon Holywell: International PHP dates with intl
  • Andrew Embler: Creating a Z-Ray Plugin for Zend Server 8.5
  • Freek Van der Herten: Speed up a Laravel app by caching the entire response
  • Lorna Mitchell: Test Your PHP Application on PHP 7
  • Sameer Borate: Cron Expression Parser in PHP
  • Paragon Initiative: Implementing Secure User Auth in PHP Applications with Long-Term Persistence
  • Simon Holywell: PHP date localisation with setlocale
  • NetTuts.com: Understand Overriding in Magento: Controllers
  • Rob Allen: Custom OAuth2 authentication in Apiiglity
  • BitExpert Blog: Think About It: PHP/PostgreSQL Bulk Performance (Part 3)
  • SitePoint PHP Blog: Defensive Programming in PHP
  • MyBuilder Tech Blog: Insertion, Removal and Inversion Operations on Binary (Search) Trees in PHP
  • Facebook HipHop Open Source Blog: Under the hood: Box’s HHVM migration
  • Tideways.io: 5 Ways to optimize Symfony Baseline Performance
  • SitePoint PHP Blog: Validating your data with Respect Validation
  • Matthew Setter: PHP South Coast 2015
  • Voices of the ElePHPant: Interview with Jacques Woodcock

    PHPDeveloper.org

  • TutsPlus.com: How to Program With Yii2: Uploading Files

    On the TutsPlus.com site there’s a new installment in their "How to Program With Yii2 Series" looking at implementing file uploads with some simple examples.

    In this How to Program With Yii2 series, I’m guiding readers in use of the Yii2 Framework for PHP. In this tutorial, I’ll guide you through the basics of uploading files and images in Yii2.

    For these examples, we’ll continue to imagine we’re building a framework for posting simple status updates, e.g. our own mini-Twitter. The image above demonstrates writing a short update while uploading a picture I took of the Taj Mahal.

    They start with a look at some of the file upload plugins that seemed like the best they found to use with Yii2: FileInput and the 2Amigos BlueImp File Uploader. They go with the first option for the rest of the tutorial, showing you how to get it installed (via Composer), updating your current database tables and changing the model to reflect these updates. Next they help you create the view with the image upload form and one to display the image result once the upload is successful (including the controller code needed).

    PHPDeveloper.org