Notes on software development

Past and future of HTML Canvas. A brief overview of 2D, WebGL, and WebGPU

What is Canvas?

Canvas is an HTML element designed for drawing using JavaScript. It acts as a container for drawing. Like other HTML elements, the Canvas has its own tag and is embedded on the page in the following way:

<canvas id="canvas">Canvas is not supported by your browser</canvas> 

All further operations with Canvas are done using JavaScript. First, we need to create a Canvas object:

const canvas = document.getElementById('canvas');

Then define the Context:

const context = canvas.getContext('2d');

In addition to the Canvas itself, we've created the Context associated with the Canvas. There are different types of Context, each providing its own set of methods or API.

How to create a PHP package. Part 4: Git, tags, packagist

In this chapter, we will push created package to github, talk a little bit about versioning, create first release, and, finally, publish the package on packagist.org to let the whole world install our library with a composer.

Github

I expect that you already know what git and github are. In a few words: git is a distributed version control system that tracks files changes, and github is a hosting service based on git which also provides other useful features. I also assume that you are already registered on github.com and installed git itself (if not, please, do it).

How to create a PHP package. Part 3: Code style

This is the third part of a series on creating a PHP package. In the previous parts, we created a project and covered it with tests.

This time we will implement a code style check to sure that our code not only works correctly but follows the style requirements. This is especially useful when working in a team and all members follow requirements.

How to create a PHP package. Part 2: PHPUnit

This is the second part of a series on creating a PHP package.

In the previous part, we initialized a project using the composer and wrote the code itself. In this part, we will integrate the PHPUnit into our project and write tests.

Code should be covered with tests. This will help to avoid bugs when modifying the code. When we connect the CI to the repository, tests will run automatically as pull requests are created.

How to create a PHP package. Part 1: Composer

If you created a useful PHP library and want to share it with others or reuse it in your other projects, it will be convenient to pack it into a separate package. In this series of articles, we'll discover how to properly organize code into a reusable package, create a structure of the project, write unit tests, create an automatic code style check, implement CI using github actions, and much more. As an example, we will write step by step a small PHP library for syntax highlighting. It will accept text and return highlighted PHP code.

JavaScript Canvas Sprite Animation

Sprite sheets have been used in game development for many years. In web development it allows you to reduce:

  • a number of HTTP requests for downloading many separate images,
  • webserver load as a result of fewer requests,
  • download time as a combined sprite sheet is smaller than the individual files.

I want to share the approach that I used in my games written with canvas and javascript. I think this is a reusable approach for animating different objects on a canvas.

To demonstrate it, I compiled a Sonic sprite sheet from the "Sonic the Hedgehog 3" game.

How I passed AWS certification exam "Developer – Associate"

Recently I've passed my second AWS certification exam "Developer - Associate". Although my preparation in many ways was similar to the preparation for Solutions Architect, which I wrote about earlier, this time the exam touched many other AWS services more deeply.

Using AWS Lambda Layers for PHP

Until recently AWS Lambda did not support PHP, but with the advent of the runtime API and layers, now we able to implement an AWS Lambda runtime in any programming language including PHP. Each layer can contain libraries, a custom runtime, or other dependencies. You can create layers, or use layers published by AWS and other AWS customers.

There is a great practical example of creating a Custom Runtime for PHP if you want to build a PHP runtime layer by yourself. In this article, we'll use partner supported PHP layer for Lambda from stackery for a quick understanding of its use.

How to test web server performance

During the development of a web application, it’s useful to know what kind of load it can hold. Today the application’s speed is one of the most important indicators and it is worth taking it seriously. A slow running application can push your users away.

To check how much your application is ready for production, you can use some utilities to test your server performance. Slow request processing speed can also help to identify incorrect server settings or scripts.

We'll cover 2 tools for understanding server-side performance: Apache Benchmark (ab) and Siege.