News Feed
Sections




News Archive
feed this:

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

Mikko Koppanen:
Memcached protocol support
November 15, 2013 @ 11:15:38

Mikko Koppanen has posted about some updates he's making to the PECL memcached extension, more specifically around binary protocol support.

There are quite a few things still missing and only binary protocol is supported at the moment, but the code seems to work reasonably well in small-scale testing. I am not sure whether this is useful for anyone, but at least it allows things such as quick prototyping of network servers, exposing sqlite database over memcached protocol etc.

An example of code using this new functionality is included in the post showing how to create both a simple sever with attached "get" and "set" handlers and a client to connect to it and enable the binary protocol.

The code is still work in progress but it's available in github: https://github.com/mkoppanen/php-memcached/tree/feature-server. Note that you need to compile libmemcached with -enable-libmemcachedprotocol and the PECL memcached extension with -enable-memcached-protocol.
0 comments voice your opinion now!
memcached binary support protocol pecl update

Link: http://valokuva.org/memcached-protocol-support/

PHPMaster.com:
Base Converting and Binary Operators
April 18, 2013 @ 11:44:05

On PHPMaster.com there's a new tutorial from Timothy Boronczyk focusing on the binary operators in PHP and using them to do some base conversions.

This article discusses PHP's binary operators and how to convert between different counting systems. Most programming books and articles only dedicate a page or two to such topics, and although using the operators is really quite simple, there's a fair amount of background knowledge one must have to use them correctly. Instead of giving the same bare-bones treatment that every other reference gives, I'll first provide you the necessary background in number theory. Armed with that knowledge, you'll be able to understand the binary counting system and base conversions… and familiarity with binary digits is the key to successful use of the binary operators!

As promised he starts off with some number theory complete with illustrations about base-10 and how the values fit into "buckets" of data. He compares this to base-2 (binary) and only then starts getting into the conversion functions. He shows the usage of things like decbin and dechex to modify the values as well as the use of bitwise and binary operators.

0 comments voice your opinion now!
converting binary bitwise operator tutorial numbertheory

Link: http://phpmaster.com/base-converting-and-binary-operators

Sameer Borate:
Storing images into a database - resolving a contentious matter
February 21, 2013 @ 11:16:45

In this new post to his CodeDiesel site Sameer Borate looks at something that's been a controversial topic with developers (not just PHP) about storing binary data, like images, in a database instead of on the local file system.

There is much discussion and argument with no final say on the issue. In one of my recent project the same issue was raised; the client and myself discussing the benefits and drawback of storing the images into a database. The project needed storing around 50,000 images, so it was important to get the question resolved satisfactorily. After much deliberation we settled on using the file system. The major factor in the decision was that we needed the database and images decoupled as we would be having multiple databases using the same set of images.

He goes on to talk about some of the things you should consider when you're deciding if storing images in the database is the right thing for your application including:

  • The bloat that can come with storing binary data (larger database size)
  • Updating images requires two operations - updating the database and updating the cached image locally
  • Images usually serve faster when they come from the filesystem through the web server
  • BLOB (a common type for binary data storage) is variable-width and can degrade performance

You can read the rest of the reasons (and get more detail on the ones above) in the rest of the post.

0 comments voice your opinion now!
images binary data storage database benefits disadvantages


Igor Wiedler:
Binary parsing with PHP
September 25, 2012 @ 12:17:41

Igor Wiedler has a new post to his blog showing how to work with binary data in your PHP applications a few different built-in functions including unpack and bindec.

Binary operations in PHP are a bit strange. Since PHP was originally a templating layer for C code, it still has many of those C-isms. Lots of the function names map directly to C-level APIs, even if they work a bit differently sometimes. For example, PHP's strlen maps directly to STRLEN(3), and there are countless examples of this. However, as soon as it comes to dealing with binary data, things suddenly become very different.

He starts off looking at "the C way" to unpack a string (getting the ASCII values of each character) and shows how *not* to do it in PHP with ord. Instead he uses "unpack", bitwise operators and bindec to work with the actual binary data of the string.

0 comments voice your opinion now!
binary parse ord unpack tutorial bindec bitwise


Dave Marshall's Blog:
Defending against Cache Stampedes
January 13, 2012 @ 13:13:08

Dave Marshall has a new post to his blog showing one method for defending against cache stampedes from assaulting your caching servers and (possibly) bringing them down.

I've recently had a problem with a rather large operation (that could probably be optimised considerably, but nevermind), where by if the cached result of the operation expired, several web server threads would attempt the operation, causing some major headaches for our database and web servers. This is something I've come across before, and is commonly(?) known as a Cache Stampede. This is bad, this post describes the basics of what I've done to deal with it.

His example uses a Zend_Cache interface to Memecache, but it could be applied in other places too. His method uses a binary semaphore to check and see if there's a "lock" and sleep for a bit before checking again. Sample code is included showing how to create this system and how to refresh the data with a new expiration on a cache miss.

0 comments voice your opinion now!
cache stampede zendcache tutorial binary semaphore miss prevention


PHP.net:
PHP 5.4.0RC4 Released!
December 28, 2011 @ 08:55:32

The latest version of PHP in the 5.4.0 release candidate series has been posted - PHP 5.4.0 RC4, complete with new features and lots of bugfixes.

The PHP development team is proud to announce the 4th release candidate of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. THIS IS A RELEASE CANDIDATE - DO NOT USE IT IN PRODUCTION! This is the 4th release candidate. The release candidate phase is intended as a period of bug fixing prior to the stable release. No new features should be included before the final version of PHP 5.4.0.

Updates in this release candidate include an update to the max_input_vars directive and a fix for a segfault in the traits code. You can find the full notes for the release in the NEWS file and can download the latest from the PHP.net site - source downloads, Windows binaries.

0 comments voice your opinion now!
release candidate windows binary news


PHP.net:
PHP 5.4 beta2 released
October 27, 2011 @ 10:12:59

The PHP.net site has a new announcement about the latest version of the language in the PHP 5.4.x series - beta 2 has been released for testing.

The PHP development team is proud to announce the second beta release of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. [...] Please help us to identify bugs by testing new features and looking for unintended backward compatibility breaks, so we can fix the problems and fully document intended changes before PHP 5.4.0 is released. Report findings to the QA mailing list and/or the PHP bug tracker.

Remember - this is not a production release, so do not use it in your live applications (unless you really like to live dangerously, of course). You can look at the NEWS file for a complete list of changes.

0 comments voice your opinion now!
beta release second windows binary qa bugtracker


Rob Allen's Blog:
Some notes on SQL Server blobs with sqlsrv
November 22, 2010 @ 11:15:33

In this new post to his blog, Rob Allen has posted notes on some of his experience in working with blobs with SQL Server using UTF-8.

This turned out to be easy enough: Use ntext, nvarchar types in the database and add resources.db.params.driver_options.CharacterSet = "UTF-8" to your application.ini

He also includes some code to fix a problem he spotted with storing binary data into a varbinary field giving him an error about string translation. The fix came in the way of replacing the direct file_get_contents assignment to a variable over to a binding method that specified the data type as well.

0 comments voice your opinion now!
sqlserver binary data insert datatype varbinary


Sameer Borate's Blog:
Unpacking binary data in PHP
September 22, 2010 @ 10:45:52

Sameer Borate has a new post to his blog today talking about a method for unpacking binary data directly in PHP - specifically in working with images.

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 shows how to use the unpack function to open up the file and pull out the raw data - including the header information that tells you what kind of file it is you're working with. There's also an example of unpacking the header contents and grabbing things like height, width and the aspect of the image.

0 comments voice your opinion now!
unpack binary data tutorial gif image


Gonzalo Ayuso's Blog:
Using CouchDb as filesystem with PHP
September 01, 2010 @ 13:41:12

In a new post to his blog Gonzalo Ayuso shows an interesting use for the CouchDB tool - using it as a filesystem for cross-server handling of things like images or other binary resources.

One of the problems I need to solve in my clustered PHP applications is where to store files. When I say files I'm not speaking about source code. I'm speaking about additional data files, such as download-able pdfs, logs, etc. Those files must be on every node of the cluster. [...] CouchDb has two great features to meet or requirements with this problem. It allows us to store files as attachments and it also allows to perform a great and very easy multi-master replica system.

He shows how use two libraries he's created to connect to the CouchDB instance and, based on this structure, be able to insert the content - a text file in this case - pull it back out, get the meta data about it and even move it to another location in the structure.

1 comment voice your opinion now!
couchdb filesystem tutorial binary file



Community Events





Don't see your event here?
Let us know!


deployment tips laravel language framework podcast symfony conference zendserver bugfix community voicesoftheelephpant developer release series interview introduction list library api

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework