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

Tomas Votruba:
Hidden Gems of PHP Packages: SymfonyFinder and SplFileInfo
Aug 14, 2018 @ 10:55:09

Tomas Votruba has continued his series covering the "hidden gem" packages he's found in his PHP development. In this latest post he focuses on two new pieces of functionality: the Symfony/Finder package and SplFileInfo.

The series on not-so-well-known packages that might save your ass more than you think continues. Today we look on files as objects.

He starts by providing some examples of where he makes use of the Finder package and how it makes working with files easier. He then shows how to get the package installed, a simple example of how to use it and some of the functionality that's included. He also details the SplFileInfo functionality that comes with the package and what information it can provide about a file.

tagged: package hiddengem tutorial symfony finder splfileinfo

Link: https://www.tomasvotruba.cz/blog/2018/08/13/hidden-gems-of-php-packages-symfony-finder-and-spl-file-info/

CodeWall:
Filtering Faulty HTML Using Purifier Package
Aug 06, 2018 @ 09:22:26

On the CodeWall site there's a tutorial posted showing you how to clean up HTML with the Purifier package, a Composer-installable service provider for Laravel that acts as an interface for the main HTMLPurifier package.

And as every programmer is an artist and makes his/her own copy of CMS to put in the content and publish on a click of a button. Every one of those websites will have a text editor on them, so we can see the result as we write our content.

You can always learn how to integrate a text/html editor on your Laravel installation on one of my posts. We set our own stylesheets for styling various attributes on our content. But for that to work correctly, we need to have a proper HTML code in place.

The tutorial then shows how to install and use the package in your Laravel application. It also includes some advanced steps to publish the configuration file and update its settings (including changes to the allowed HTML tags and allowed CSS properties).

tagged: tutorial laravel htmlpurifier package install configure

Link: https://www.codewall.co.uk/filtering-faulty-html-using-purifier-package/

Sameer Borate:
Using the TOML configuration format in your applications
Aug 01, 2018 @ 12:54:59

In this new post to his site Sameer Borate looks at using the TOML configuration file format in a PHP application.

As any one who has programmed knows about configuration files. Configuration files are mostly text files used to configure the parameters and initial settings for computer programs – mostly user applications, operating system settings.

[...] In this post we will look into parsing TOML files in PHP. TOML is a configuration file format that is intended to be easy to read due to its obvious semantics and is designed to map unambiguously to a dictionary data structure. “TOML”, the name, is an acronym for “Tom’s Obvious, Minimal Language” referring to its creator Tom Preston-Werner.

He starts with an example of a configuration file in the TOML format and, following the installation/used of the yosymfony/toml library, the result of it being parsed. He also includes an example of using the same library to build out a TOML configuration and dump it to a string for output.

tagged: toml configuration file format introduction tutorial package

Link: https://www.codediesel.com/data/using-the-toml-configuration-format-in-your-applications/

Exakat Blog:
Versions impact on PHP code bases
Aug 01, 2018 @ 10:03:27

On the Exakat blog there's a new post covering some of the impact that PHP versions have on codebases they've reviewed in the normal course of their product's analysis and the requirements of Open Source software.

With the upcoming PHP 7.3, the question of the next migration is back on our tables. We’ll hear a strange mix of begging to move to the new versions for features and security, mixed with a constant threatening that some old versions will soon be unmaintained or worse. Indeed, there is versions impact on PHP code bases.

Particular witnesses of that evolution are open source projects. They usually have to support a wide range of versions, and in the same time, are actively encouraged to use the newest features. It is a delicate work of balancing compatibility and progress.

To observe the way Open Source projects handle the evolution of PHP, we have audited 1977 Open source PHP projects, by linting them with PHP versions from 5.5 to 7.3. This taught us the impact of PHP on code, over a long period of coding. Let’s review them.

The post starts by talking about linting of PHP files (checking the syntax for issues but not executing the contents). It then shares some statistics about the number of Open Source projects that lint on every build and how it has trended over time. They also share some results on the age of packages that are in wide use, showing that the ration of "old code" to "young code" is surprisingly similar.

tagged: staticanalysis opensource package lint age results statistics

Link: https://www.exakat.io/versions-impact-on-php-code-bases/

Paul Jones:
Atlas ORM Integration with Symfony
Jul 31, 2018 @ 12:16:26

Paul Jones has a quick post covering the use of his Atlas.Orm package in a Symfony application, showing how to easily integrate the two.

Are you using Symfony 4? Do you want to use Atlas with it? We now have a Symfony bundle and Flex recipe that makes installation and integration a breeze. Two commands and one .env file edit, and you’re ready to go.

He includes the commands you'll need to get it installed and generate the skeleton mapper files from your database. Symfony then automatically injects the Atlas instance from the container (code example included). He ends the post linking to other resources about defining relationships, managing transactions and handling events with the Atlas.Orm package.

tagged: atlasorm integration symfony flex bundle package tutorial

Link: http://paul-m-jones.com/archives/6916

Tomas Votruba:
Hidden Gems of PHP Packages: NetteUtils
Jul 31, 2018 @ 10:36:37

Tomas Votruba has a new post to his site sharing what he calls a "hidden gem" of a PHP package that he finds useful: the NetteUtils package. This is the first part of a series of posts dedicated to packages he finds helpful.

In this series, I will show you not-so-known PHP packages, that I happily use in my daily workflow. They're hard to describe in few words for their various features, but awesome and simple to use.

Today we start with NetteUtils package.

He starts with a few points about why he uses the library (including mentioning some specific functionality) and how to get it installed in your own application. He then goes through some example code showing the functionality he uses including the Strings and FileSystem classes.

tagged: hiddengem package netteutils detail install usage tutorial

Link: https://www.tomasvotruba.cz/blog/2018/07/30/hidden-gems-of-php-packages-nette-utils/

Laravel News Podcast:
Episode 65 - Jigsaws, Git tools, and Laravel development packages
Jul 19, 2018 @ 11:04:26

The Laravel News podcast, hosted by Jacob Bennett and Michael Dyrynda, has released their latest episode: Episode #65 - Jigsaws, Git tools, and Laravel development packages. In this episode Michael and Jacob also talk about:

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed to get updates when new shows are released.

tagged: laravelnews podcast ep65 jigsaw git laravel package

Link: https://laravel-news.com/podcast/65

Sameer Borate:
Convert CSV to Excel in PHP
Jul 12, 2018 @ 09:50:24

Sameer Borate has a new post to his site sharing a method for converting a CSV to an Excel document using PHP. While you can open a CSV file with Excel correctly, using this method (and library) allows for more control over the end result.

During a recent data conversion project I needed to convert around 250 CSV files to Excel (xls) format. As this was a PHP project I decided to write a small PHP script using the PhpSpreadsheet library.

He then walks through the installation (via Composer) and use of the library to take in a simple CSV of countries and write it out as a .xls file in a single worksheet. He also includes a modification of the script that can be run from the command line, taking in arguments for the source file and the destination.

tagged: convert cvs excel document worksheet tutorial phpspreadsheet package

Link: https://www.codediesel.com/php/convert-csv-to-excel-format-in-php/

Laravel News:
Twine: String Manipulation, Leveled Up
Jul 11, 2018 @ 09:19:02

On the Laravel News site there's a post spotlighting an interesting string manipulation library (Twine) and some of its basica features and use.

Twine is a stand-alone PHP 7 package by Chris Kankiewicz for string manipulation and comparison with an expressive fluid syntax.

They provide several code examples showing the package in action:

  • adding padding to the left/right
  • uppercase/lowercase
  • starts with/contains/ends with
  • converting the string to a hash
  • basic string formatting

The package also makes use of a fluent interface, making it easier to stack multiple operations onto a string (like checking to see if a substring equals a value). You can find out more about the package on its GitHub repository.

tagged: string manipulation package library twine tutorial

Link: https://laravel-news.com/twine-string-manipulation-leveled-up

TutsPlus.com:
Parsing HTML With PHP Using DiDOM
Jul 05, 2018 @ 10:48:35

The TutsPlus.com site has posted a tutorial showing you how to use the DiDOM library to parse HTML in PHP. The DiDOM is a "simple and fast parser" packed with a lot of functionality for parsing, searching and modifying HTML.

Every now and then, developers need to scrape webpages to get some information from a website. For example, let's say you are working on a personal project where you have to get geographical information about the capitals of different countries from Wikipedia. Entering this manually would take a lot of time. However, you can do it very quickly by scraping the Wikipedia page with the help of PHP. You will also be able to automatically parse the HTML to get specific information instead of going through the whole markup manually.

In this tutorial, we will learn about a fast, easy-to-use HTML parser called DiDOM. We will begin with the installation process and then learn how to extract information from different elements on a webpage using different kinds of selectors like tags, classes, etc.

The tutorial starts by helping you get the package installed (via Composer) and provides a simple example of using it to parse either a string of HTML, a local document or a remote site. It then walks you through using the search functionality built into the library, using either CSS selector type strings. They also include examples of traversing the DOM, updating element attributes, and adding/removing/replacing elements.

tagged: tutorial dom parse html didom package elements

Link: https://code.tutsplus.com/tutorials/parsing-html-with-php-using-didom--cms-31242