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

Sergey Zhuk:
Amp Promises: From Generators To Coroutines
Feb 15, 2018 @ 15:27:05

In a new post to his site Sergey Zhuk takes a look at generators in PHP and shows how they're integrated into coroutines and promises to help with the chunked asynchronous processing.

Generators become available in PHP since version 5.5.0. The main idea is to provide a simple way to create iterators but without creating a class that implements Iterator interface. A generator function looks like a normal function, except that instead of returning the result once, a generator can yield as many times as it needs to in order to provide the values to be iterated over.

[...] So, let’s wrap up what we know about generators:

  • interruptible/resumable functions
  • use yield rather than (or in addition to) return
  • values/exceptions can be send/thrown into
  • behave like iterator

All these generator features are used in <a href="https://amphp.org/>Amp to implement coroutines.

The post starts out with a pretty detailed look at generators in PHP and the functionality they offer. It covers sending values into the generator, exception handling and the use of the yield statement. It then moves over to describing coroutines, promises and deferred handling. Generators make it easier for them to chunk up the operation one piece at a time rather than requiring all data up front.

tagged: amp promise coroutine generator tutorial integration

Link: http://sergeyzhuk.me/2018/02/15/amp-coroutines/

Niklas Keller:
The Magic Behind Async PHP
Nov 07, 2017 @ 16:27:51

Niklas Keller has a post to his site covering the magic behind async PHP and how it can help your application gain some performance by working around the typical PHP execution flow.

Async PHP allows a massive speedup of applications by leveraging non-blocking I/O. It allows making multiple HTTP requests in parallel or any other way of I/O multiplexing. But what’s the magic behind it? How does it actually work?

He starts with a brief explanation of the difference between blocking and non-blocking I/O, pointing out that the main difference is the use of streams. He includes a bit of code to help illustrate but moves quickly on to talking about the Amp PHP package. This library allows for easier (and faster) development of non-blocking processes using an event loop. He also shares a package that was created to help make it even simpler by providing an abstraction layer on top of the Input and Output streams.

tagged: async language amp library blocking nonblocking introduction

Link: https://blog.kelunik.com/2017/11/06/magic-behind-async-php.html

SitePoint PHP Blog:
Writing Async Libraries – Let’s Convert HTML to PDF
Feb 21, 2017 @ 15:58:05

The SitePoint PHP blog has another tutorial posted from author Christopher Pitt looking at writing async libraries with PHP. In this particular article he focuses on just one of many tasks an asynchronous library could perform: converting HTML to PDF documents.

I can barely remember a conference where the topic of asynchronous PHP wasn’t discussed. I am pleased that it’s so frequently spoken about these days. There’s a secret these speakers aren’t telling, though: "Making asynchronous servers, resolving domain names, interacting with file systems: these are the easy things. Making your own asynchronous libraries is hard. And it’s where you spend most of your time!"

The reason those easy things are easy is because they were the proof of concept – to make async PHP competitive with NodeJS. [...] Today, we’re going to look at a few ways to make your application code work well in an asynchronous architecture. Fret not – your code can still work in a synchronous architecture, so you don’t have to give anything up to learn this new skill. Apart from a bit of time…

He starts with some theory about things in the async world including callbacks, promises and what they might look like in PHP-land. He then starts in on the creation of the PDF files, creating a "Driver" class to handle some of the logic and using the Dompdf library to do the heavy lifting (the conversion from HTML to PDF). He walks through the code required for this class then moves on to the code, using the Amp project, to handle the async operations. He then creates a simple set of web accessible endpoints that call the Driver class with some basic attributes and performing the conversion. He ends the post talking about porting the parallel driver to other systems (such as ReactPHP) and a few simple steps if you need to move back to the synchronous world.

tagged: asynchronous conversion dompdf html pdf tutorial amp

Link: https://www.sitepoint.com/writing-async-libraries-lets-convert-html-to-pdf/

Symfony Finland:
How to implement AMP (Accelerated Mobile Pages) on the eZ Platform CMS
Aug 29, 2016 @ 16:44:58

On the Symfony Finland site they've posted an introductory article showing you how to implement accelerated mobile pages (AMP) in an application based on the ez Platform CMS.

Accelerated Mobile Pages is an initiative from Google to speed up mobile browsing. AMP is an open standard based on HTML. It enforces performance by limiting functionality and includes remote caching.

Given Google's continuing dominance search both publishers and CMS vendors need to take AMP into account. In this article you'll learn the basics of how to implement AMP with eZ Platform CMS and Symfony.

The post starts out with a bit of background about AMP and how it relates back to the main content of the site. With that knowledge in place the author moves into the code, showing how to use annotations to create the route, building and returning the template including the meta and link tags required to link this AMP version back to the main content page.

tagged: tutorial amp mobile pages accelerated symfony twig meta link

Link: https://www.symfony.fi/entry/how-to-implement-amp-accelerated-mobile-pages-ez-platform-cms

Alexander Netkachev's Blog:
Easy Apache/PHP install
Dec 01, 2006 @ 13:52:00

On Alexander Netkachev's blog today, there's a walk-through of a light and easy method for getting PHP and Apache up and running. It makes use of the Installer Technical Preview utility to make live simpler.

I created the installer, which primary goal is to provide the developer with command-line tools for basic Apache/PHP/MySQL management tasks.

This a preview version of AMP installer and configurator. Although, it is very far from being a real time-proven and tested installation method, with your help and effort we can make it better.

There's a link for the download and a brief How-To on using the package to get things up and running quickly. There's also two things on the To-Do list for upcoming versions - installers for various other databases and support for automatic installation of modern PHP applications (like WordPress, phpbb, etc).

tagged: easy install apache technical preview download installer amp package easy install apache technical preview download installer amp package

Link:

Alexander Netkachev's Blog:
Easy Apache/PHP install
Dec 01, 2006 @ 13:52:00

On Alexander Netkachev's blog today, there's a walk-through of a light and easy method for getting PHP and Apache up and running. It makes use of the Installer Technical Preview utility to make live simpler.

I created the installer, which primary goal is to provide the developer with command-line tools for basic Apache/PHP/MySQL management tasks.

This a preview version of AMP installer and configurator. Although, it is very far from being a real time-proven and tested installation method, with your help and effort we can make it better.

There's a link for the download and a brief How-To on using the package to get things up and running quickly. There's also two things on the To-Do list for upcoming versions - installers for various other databases and support for automatic installation of modern PHP applications (like WordPress, phpbb, etc).

tagged: easy install apache technical preview download installer amp package easy install apache technical preview download installer amp package

Link:

IT Manager's Journal:
Court library AMPs up
Dec 28, 2005 @ 13:26:56

Via this new post from LinuxLibrarian.org today, there's a pointer to this new article on the IT Manager's Journal site about the Supreme Court Library of North Carolina's move to an Apache/MySQL/PHP combination.

Until last year, [Ronald] Diener's organization was paying thousand of dollars a year to a library software vendor, but the vendor's services had become inadequate for the task. The court's IT team determined that they could develop a better, cost-effective in-house solution that would at the same time be open to participation from outside.

The open source option available through Apache, MySQL, and PHP (AMP) would serve as a resource to collaborate with other organizations and libraries, even internationally, in creating a continually upgradeable software portfolio. This solution would both cut costs and enhance the value of what could be offered to their own clients and a larger audience of legal professionals.

They do mention the comment made about finding documentation on implementing an AMP setup, but other than that, they seem happy overall with the system - plus it's already saving them money.

tagged: apache mysql amp court library sharing search apache mysql amp court library sharing search

Link:

IT Manager's Journal:
Court library AMPs up
Dec 28, 2005 @ 13:26:56

Via this new post from LinuxLibrarian.org today, there's a pointer to this new article on the IT Manager's Journal site about the Supreme Court Library of North Carolina's move to an Apache/MySQL/PHP combination.

Until last year, [Ronald] Diener's organization was paying thousand of dollars a year to a library software vendor, but the vendor's services had become inadequate for the task. The court's IT team determined that they could develop a better, cost-effective in-house solution that would at the same time be open to participation from outside.

The open source option available through Apache, MySQL, and PHP (AMP) would serve as a resource to collaborate with other organizations and libraries, even internationally, in creating a continually upgradeable software portfolio. This solution would both cut costs and enhance the value of what could be offered to their own clients and a larger audience of legal professionals.

They do mention the comment made about finding documentation on implementing an AMP setup, but other than that, they seem happy overall with the system - plus it's already saving them money.

tagged: apache mysql amp court library sharing search apache mysql amp court library sharing search

Link:


Trending Topics: