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

Sameer Borate:
Unpacking binary data in PHP
Apr 04, 2018 @ 14:19:40

Sameer Borate has a new post to his Code Deisel blog showing how to unpack binary data in PHP making use of the pack and unpack functions.

Working with binary files in PHP is rarely a requirement. However when needed the PHP ‘pack’ and ‘unpack’ functions can help you tremendously. To set the stage we will start with a programming problem, this will keep the discussion anchored to a relevant context. The problem is this : We want to write a function that takes a image file as an argument and tells us whether the file is a GIF image; irrelevant with whatever the extension the file may have. We are not to use any GD library functions.

He starts by briefly covering the "metadata" that binary files contain in their headers about the type of file and, more specifically, what the content for a GIF looks like. He follows this with an example of using unpack to provide a readable version of the file's binary content. He then uses this in an is_gif function to read the contents of a file, check the header format and ensure the version is either GIF87a or GIF89a. He also includes the code for another method to get attributes about the file like height, width and the aspect ratio. He ends the post with more details on the contents of the header and what each character means.

tagged: binary data unpack pack tutorial gif image

Link: https://www.codediesel.com/php/unpacking-binary-data/

Fabien Potencier:
Symfony 4: Unpack the Packs
Jan 04, 2018 @ 17:53:47

Fabien Potencier of the Symfony project has a post on his site that introduces Symfony Packs, groupings of useful packages that can enhance the functionality of your application without having to manually load each package individually.

We get a lot of positive feedback on Symfony 4. You love the new directory structure. You love the simplicity of using services without configuring anything. And you love the automation that Flex provides. It makes me happy and proud.

[...] But one issue I hear sometimes is that it is more complex to start a new project. [...] You loved the simplicity of starting a project with the Symfony Standard Edition. Is it nostalgia? Perhaps. Would it be possible to get the best of both world? Certainly!

The Packs are "metapackages" that Composer uses to bundle dependencies together that relate either in functionality or as defined by a custom configuration. The article gives an example using the symfony/orm-pack pack and talks about how you can use it as-is or you can "unpack" it into its separate packages and automatically update the composer.json with the result.

tagged: symfony symfony4 pack composer metapackage introduction

Link: http://fabien.potencier.org/symfony4-unpack-the-packs.html

Edin Kadribasic's Blog:
New Snapshot Capabilities
Apr 30, 2007 @ 14:21:00

In an effort to provide as much information and code about the PHP builds as possible, Edin Kadribasic (with some help from John Mertic) has created some new abilities for the snapshot build process:

Up till now we provided only the debug pack for the latest snap but several people have asked if it was possible to make one available for each snap that was provided on the site. The PECL bundle and the installer were not provided at all (although pecl4win site provides a build of PECL extensions).

As a result, he's generated and posted these packages for the latest PHP releases:

He also makes a request to other PHP-ers out there for suggestions of how to include these builds on the Downloads page right alongside the normal PHP downloads.

tagged: snapshot build pack debug pecl download snapshot build pack debug pecl download

Link:

Edin Kadribasic's Blog:
New Snapshot Capabilities
Apr 30, 2007 @ 14:21:00

In an effort to provide as much information and code about the PHP builds as possible, Edin Kadribasic (with some help from John Mertic) has created some new abilities for the snapshot build process:

Up till now we provided only the debug pack for the latest snap but several people have asked if it was possible to make one available for each snap that was provided on the site. The PECL bundle and the installer were not provided at all (although pecl4win site provides a build of PECL extensions).

As a result, he's generated and posted these packages for the latest PHP releases:

He also makes a request to other PHP-ers out there for suggestions of how to include these builds on the Downloads page right alongside the normal PHP downloads.

tagged: snapshot build pack debug pecl download snapshot build pack debug pecl download

Link:

Greg Beaver's Blog:
problem with PHP_Archive-based phars tracked to odd unpack() bug
Jan 08, 2007 @ 17:02:00

Users of the PHP_Archive PEAR package should check out Greg Beaver's latest post for some information about the latest version of the package:

I just pushed out a release of PHP_Archive 0.9.1. This release fixes a bug that affects 64-bit users of PHP 5.2 and newer. Basically, the unpack() function does not behave in a predictable way when unpacking large integers. This is a known bug, and is documented at the manual page, although I was unaware of the issue until today.

He gives the example code that would cause the problem and a more correct version that would allow the package to work with all versions of PHP (previously, it would fail due to a bad return from pack). The latest version of the package can be grabbed from it PEAR page or via the "pear" command to grab it automatically.

tagged: phparchive pear package bug pack release phar phparchive pear package bug pack release phar

Link:

Greg Beaver's Blog:
problem with PHP_Archive-based phars tracked to odd unpack() bug
Jan 08, 2007 @ 17:02:00

Users of the PHP_Archive PEAR package should check out Greg Beaver's latest post for some information about the latest version of the package:

I just pushed out a release of PHP_Archive 0.9.1. This release fixes a bug that affects 64-bit users of PHP 5.2 and newer. Basically, the unpack() function does not behave in a predictable way when unpacking large integers. This is a known bug, and is documented at the manual page, although I was unaware of the issue until today.

He gives the example code that would cause the problem and a more correct version that would allow the package to work with all versions of PHP (previously, it would fail due to a bad return from pack). The latest version of the package can be grabbed from it PEAR page or via the "pear" command to grab it automatically.

tagged: phparchive pear package bug pack release phar phparchive pear package bug pack release phar

Link:


Trending Topics: