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

TutsPlus.com:
What Are the WordPress PHP Coding Standards?
May 23, 2018 @ 17:51:35

On the TutsPlus.com site they've posted a tutorial sharing some of the current WordPress coding standards when it comes to both the structure and syntax of the code written in WordPress (and suggested for plugins as well).

You can find the full WordPress PHP coding standards in the tagged: wordpress coding standard tutorial example

Link: https://webdesign.tutsplus.com/tutorials/php-coding-standards--cms-31203

Tomas Votruba:
Try PSR-12 on Your Code Today
Apr 10, 2018 @ 15:51:19

In a post to his site Tomas Votruba shows you how to test the PSR-12 standard on your current codebase using some custom PHP-CS-Fixer rules. The PSR-12 standard is a recommendation from the PHP-FIG group about consistency in coding styles and formatting. It expands and replaces the previous PSR-2 standard.

The standard is still behind the door, but feedback, before it gets accepted, is very important. After accepting it will be written down and it will be difficult to change anything.

Try PSR-12 today and see, how it works for your code.

Korvin Szanto, a developer working on the PHP-CS-Fixer project, has put together a commit with the rules to update and enforce the PSR-12 coding standard. The post shows how to install these rules and how to change up your YAML configuration to include them. He also includes a discussion about agreeing/disagreeing with the coding standard idea and gives examples of two rules he personally doesn't agree with.

tagged: psr12 coding standard phpcsfixer rules custom tutorial

Link: https://www.tomasvotruba.cz/blog/2018/04/09/try-psr-12-on-your-code-today/

Tomas Votruba:
New in Coding Standard 4: Long Line Breaks Automated and 3 Legacy Prevention Fixers
Apr 02, 2018 @ 14:51:11

Tomas Vortuba has continued his series covering the changes in the Easy Coding Standard for Symfony-based applications and the changes in version 4. In this new article he covers the updates around line breaks and legacy fixes.

Legacy code prevention, lines automated and clear naming of classes in huge projects. That all is coming to Coding Standard 4 (still in alpha).

Are you curious what work will now these 4 news fixers handle for you? Look inside.

He then goes through each of the changes and includes both the configuration changes to use it and what code changes it will make:

  • Let Coding Standard handle Line Length for You
  • Choose Line Length to Match Your Display
  • Keep Legacy Far Away with New ForbiddenStaticFunctionSniff
  • Prevent & references with ForbiddenStaticFunctionSniff
  • Clear Child Class Naming Once and For All with ClassNameSuffixByParentFixer

You can find out more about the standard in this project on GitHub.

tagged: symfony coding standard version4 linebreak legacy fix

Link: https://www.tomasvotruba.cz/blog/2018/03/29/new-in-coding-standard-4-long-line-breaks-automated-and-3-legacy-prevention-fixers/

Tomas Votruba:
New in Easy Coding Standard 4: Clean Symfony Standard with Yaml and Services
Mar 27, 2018 @ 14:48:36

Tomas Votruba has written up a new post to his site sharing an update to a project he has to make it easier to enforce various coding standards in your application's codebase. In this update he talks about the Easy Coding Standard project's v4 alpha that includes a "clean" Symfony standard with support for Yaml and Services.

I wrote about news in Easy Coding Standard 3 a while ago. EasyCodingStandard 4 is not released yet (still in alpha), but soon you'll be able to use all the news I'll show you today.

And what are they? Neon to Yaml, semi-static to Services, customizable caching, even simpler skipper, short bin and more.

He breaks the new features down into a list of six updates:

  • Configure Caching Directory
  • Skip Anything, Anywhere
  • Short vendor/bin/ecs is the King
  • DI Migration Finished: From Neon to Yaml
  • From Semi-Static Checkers to Services as First-Class Citizen
  • Good Bye Neon Class Autocomplete Or not?

For each there's a brief snippet showing how to configure it a brief description of what it enforces.

tagged: easycodingstandard v4 alpha yaml services clean standard

Link: https://www.tomasvotruba.cz/blog/2018/03/26/new-easy-coding-standard-4-clean-symfony-standard-with-yaml-and-services/

Matthew Weier O'Phinney:
PSR-15
Jan 24, 2018 @ 16:43:53

In a new post to his site Matthew Weier O'Phinney, lead developer on Zend Framework and representative in the PHP-FIG, covers the acceptance of PSR-15 by the group. PSR-15 relates to the creation of server request handlers and middleware that can use PSR-7 formatted messages.

Yesterday, following a unanimous vote from its Core Committee, PHP-FIG formally accepted the proposed PSR-15, HTTP Server Handlers standard.

This new standard defines interfaces for request handlers and middleware. These have enormous potential impact on the PHP ecosystem, as they provide standard mechanisms for writing HTTP-facing, server-side applications. Essentially, they pave the way for developers to create re-usable web components that will work in any application that works with PSR-15 middleware or request handlers!

He starts with a bit of background around the initial idea of the standard and some of the discussions that came up around it. The initial draft of the standard was modified to more correctly handle issues around response modification and the use of "handlers" for request/response manipulation. He then covers the final version of the standard, defined in the standard's documentation and enforceable via the psr/server-handler interface. Finally he covers how to use this to create re-usable middleware and an example using Expressive.

tagged: phpfig psr15 standard request response middleware handler

Link: https://mwop.net/blog/2018-01-23-psr-15.html

Symfony Blog:
The end of the Symfony Standard Edition
Jan 10, 2018 @ 17:54:34

On the Symfony blog there's a post with a major announcement for the users of the framework - the end of the Symfony Standard Edition, a release version that tried to bundle in the common tools a developer might need.

When I started to work on Symfony 2 many moons ago, I decided to create a set of decoupled components instead of a monolith framework like symfony 1. This choice was probably one of the key reasons of the immediate success of Symfony 2. [...] Of course, people don't want to assemble the components themselves when starting a new project. To fill the gap, we created the Flex was born. [...] Thanks to the new Flex approach, we've decided to not provide the Symfony Standard Edition for Symfony 4.0.

In the post Fabien talks about some of the history behind the Standard Edition including why it was made and what problems it solved. He then points out that, with the introduction of Flex, many of the issues and flexibility the SE lacked are worked out. While it is a little more complex to get started with a Flex application, the unpacking functionality helps with bringing in bundles of packages related packages without having to require each individually.

tagged: symfony standard edition endoflife end community flex symfony4

Link: https://symfony.com/blog/the-end-of-the-symfony-standard-edition

Laravel News:
Generate a JSON Feed with Laravel
May 24, 2017 @ 15:49:46

In a new tutorial posted to the Laravel News site Eric Barnes shows you how to easily create JSON feed output from the data in a Laravel application. JSON feed is a new standard that's been defined to try to bring more structure to JSON responses for feeds, following in the tradition of RSS feed structure.

JSON Feed is a new standard to formalize a JSON based RSS feed that aims to simplify creating feeds by doing away with the XML standard. Implementing a feed for your site is simple, and the spec is surprisingly clear.

[...] I just implemented this feed format for Laravel News, and you can find the results here. As a quick example let’s go through setting up a feed like this.

He then walks you through the code required to create the feed, sharing a listing of posts (the latest 20) from the Laravel News site. He then defines the main feed data, adds in each of the posts to the "items" set and returns the resulting array for translation into JSON output.

tagged: jsonfeed standard laravel tutorial output json feed

Link: https://laravel-news.com/generate-a-json-feed-with-laravel

Dotkernel.com:
What is PSR-7 and How to Use It
May 22, 2017 @ 15:18:50

On of the standards that have come out of the PHP-FIG (PHP Framework Interoperability Group) in the past few years has been PSR-7, a standards definition for working with HTTP requests and responses as PHP objects. While those that have worked with most of the PHP frameworks out there may be familiar with the concept, it can be confusing if you're just getting started with the idea. In this post on the Dotkernel site they introduce PSR-7, talking about its goals and what it defines to help bring everyone on the same page for HTTP requests.

PSR-7 is a set of common interfaces defined by PHP Framework Interop Group. These interfaces are representing HTTP messages, and URIs for use when communicating trough HTTP.

Any web application using this set of interfaces is a PSR-7 application.

They start off by defining (and linking to) the different interfaces involved in the PSR-7 specification (the spec doesn't define functionality, only the structure). From there the tutorial uses the Zend Diactoros component to illustrate an implementation of the PSR-7 structure. They cover two of the main tasks when working with HTTP requests/responses: working with the headers and fetching/writing to the body.

tagged: psr7 phpfig standard http request response introduction

Link: https://www.dotkernel.com/dotkernel3/what-is-psr-7-and-how-to-use-it/

Community News:
Exakat - Static analysis tools for PHP
Feb 27, 2017 @ 20:25:25

On the Exakat GitHub account Damien Seguy has put together a pretty complete list of static analyzers you can use for your PHP applications.

The list is broken down into the types of scanners:

  • Bugs finders
  • Coding standards
  • DIY
  • Fixers
  • Metrics
  • SaaS
  • Misc

Each section includes a good list of tools and links to each of them (usually just to other GitHub repositories but some go to actual project pages). There's a lot of them to look through but be careful to evaluate the current state of the project. Just because it's linked here doesn't mean it's a complete tool.

tagged: static scanner tool language bug standard metrics saas list

Link: https://github.com/exakat/php-static-analysis-tools

Dev.to:
PHP 7.2: The First Programming Language to Add Modern Cryptography to its Standard Library
Feb 14, 2017 @ 18:10:29

In this post to the dev.to site Scott Arciszewski talks about a milestone in the PHP language, it being the first language to "add modern cryptography to its standard library" (PHP 7.2).

Last week, the voting phase closed on an RFC to add libsodium to PHP 7.2. The result was unanimous (37 in favor, 0 against).

When version 7.2 releases at the end of the year, PHP will be the first programming language to adopt modern cryptography in its standard library.

He goes on to talk about what "modern cryptography" is describing concepts like secure primitives and showing example of the high-level API the integration will provide. The post finishes out with a rebuttal against some of the nay-sayers around PHP and its reputation for security. They say that there's "no way PHP is more secure than " so Scott compares this libsodium addition to some of the features in other languages and where they're lacking in relation.

tagged: programming language cryptography standard library libsodium php72

Link: https://dev.to/paragonie/php-72-the-first-programming-language-to-add-modern-cryptography-to-its-standard-library


Trending Topics: