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



Symfony Finland:
State of GraphQL PHP libraries and Symfony integrations in 2017
Nov 15, 2017 @ 11:16:39

On the Symfony Finland site, there's a post that looks at the current state of GraphQL PHP libraries in 2017 and how they are integrated with applications using the Symfony framework.

GraphQL has continued to gain momentum over the course of 2017. While it's certainly not a replacement for REST in all cases, it does provide consumers of Content APIs, etc. better ergonomics than general purpose RESTful interfaces. For PHP there are currently two popular libraries, both of which have Symfony integration Bundles.

The post starts by talking about implementing GraphQL functionality in your own application and mentions the two main libraries currently used: Webonyx GraphQL PHP and Youshido GraphQL. It goes on to talk about the integrations both of these provide as bundles and a bit about what each has to offer. The post then wraps up with a look forward to the Symfony Flex support they provide and a few links to other resources about GraphQL and its use in Symfony applications.

tagged: symfony framework graphql library bundle webonyx yushido

Link: https://symfony.fi/entry/state-of-graphql-php-libraries-and-symfony-integrations-in-2017

Alison Gianotto:
So You Ran Composer as Root...
Nov 15, 2017 @ 10:50:09

Alison Gianotto has an article posted to her since basically answering the "now what?" question resulting from you running Composer as root on your system.

Composer is a PHP dependency manager that’s used in just about any modern PHP application, and it works similarly to how Bundler works for Ruby.

Even though Composer itself gives you a warning about not running it as root, lots of people disregard this warning and run it as root anyway. We run into this issue a lot on my open source asset management project, Snipe-IT, so I figured I’d write up how to fix this if you inadvertently (or advertently) ran composer as root.

She starts by describing the difference between "installing Composer as root" and "running the Composer install as root" (two very different things). She points out that, while Composer tries to prevent the second but permissions errors sometimes cause people to move forward as root anyway, despite the warning. She then shows how to fix the permissions issues so it can be run as a normal user, updating the files in .composer for the root account and re-running the install.

tagged: composer root permission fix tutorial cache

Link: https://snipe.net/2017/11/15/so-you-ran-composer-as-root/

Rob Allen:
Implementing CORS in Zend Expressive
Nov 15, 2017 @ 09:20:13

In a new post to his site Rob Allen shows you how to implement CORS in a Zend Expressive application through the use of a simple middleware wrapper that sends the appropriate headers.

On a recent project, I needed to implement CORS support for my Expressive API. The easiest way to do this is to use Mike Tuupola's PSR-7 CORS Middleware.

As this is a standard Slim-Style PSR-7 middleware implementation, we need to wrap it for Expressive, so we make a factory. [...] We then register this in our AppConfigProvider::getDependencies() by adding to the factories key.

He includes the code and configuration changes required to make it all work and includes example output of a request (with headers) from a curl call to the API. He also includes a section on working with JSON error responses and ProblemDetails for when there are issues related to the current CORS policy definition.

tagged: cors tutorial zendexpressive middleware json error problemdetails

Link: https://akrabat.com/implementing-tuupola-cors-in-expressive/


Community News:
Latest PECL Releases (11.14.2017)
Nov 14, 2017 @ 08:05:02

Latest PECL Releases:

  • couchbase 2.4.2
    * PCBC-515: allow to specify expiration for subdocument mutations

    • PCBC-509: implement fulldoc operations for subdoc API
    • PCBC-442: fail fast view requests on ephemeral buckets
    • PCBC-513: make public API non-final (remove final attribute from classes and methods)
  • parle 0.7.3
    - Fix broken package
  • parle 0.7.2
    - Implemented token callbacks - Implemented unicode character class support, available with --enable-parle-utf32
  • ip2location 8.0.1
    fix license issue
tagged:

Link:

Jordi Boggiano:
PHP Versions Stats - 2017.2 Edition
Nov 13, 2017 @ 11:51:01

Jordi Boggiano is back with the latest round of his PHP version statistics as gathered from the information provided by the Composer package management tool for PHP.

It's stats o'clock! See 2014, 2015, 2016.1, 2016.2 and 2017.1 for previous similar posts.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last month for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

He then shares the results of the statistics including the total number of users for each version of the language and the difference in just the last 6-7 months. PHP 7.1 has pulled out as a front-runner with PHP 7.0 coming in closely after. He also shows some historical data showing the decline of the 5.x versions and the rise of 7.x versions over the past years. The post ends with information about the percentage of requirements in packages with 5.6 taking the lead but not by much.

tagged: composer language version usage statistics 2017

Link: https://seld.be/notes/php-versions-stats-2017-2-edition

PHPUgly Podcast:
Episode #83 - Self Titled
Nov 13, 2017 @ 10:21:13

The PHPUgly podcast, hosted by PHP community members Eric Van Johnson, John Congdon and Thomas Rideout, has posted their latest episode - Episode #83: Self Titled.

Topics mentioned in this episode include:

You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly for offline listening. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter for updates when new shows are released.

tagged: phpugly podcast ep83 selftitled

Link: http://www.phpugly.com/83

Symfony Finland:
Attaching React.js to a template rendered on the server with Twig
Nov 13, 2017 @ 09:27:49

On the Symfony Finland blog there's a new tutorial posted sharing the results of their effort to get React.js to play nice with Twig, a popular PHP templating library, via a server-side generated template.

React.js is a JavaScript view library that allows developers to create interfaces is a structured way based on a hierarchical component structure. React can either create the DOM structure from scratch, or attach to an existing one rendered by the server to speed up the first load.

If you create Twig templates that match the React rendering, you can take advantage of this feature without a complicated rendering setup.

While there were other methods created to try to solve the problem (rendering the React.js template on the server side) they show a better way via React.js 16 and Twig templates. Code is included showing how to create a simple React application, and how to hook in Twig via a "hydrate" call to pull in the content. React.js has a bit of an issue by default but a little extra work on the Twig side fixes that (see the post for the solution on that one).

tagged: reactjs template render twig serverside inject content tutorial

Link: https://symfony.fi/entry/attaching-react-js-to-a-template-rendered-on-the-server-with-twig