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

PHPMaster.com:
Let's Talk: Efficient Communication for PHP and Android, Part 2
Jun 05, 2012 @ 18:19:33

On PHPMaster.com today they've posted the second part of their series looking at combining a PHP backend and an Android application (by Matt Turland). In the previous article, he helped you set up some of the Android side to be able to reach out to a PHP web service. In this second part he gets into the sending and receiving of messages between the client and server.

Part 1 of this series focused on getting the Android application set up to make an HTTP request. In part 2, we’ll focus on implementing the use of data serialization and compression on the Android and PHP sides of the request.

He has it broken up into the different steps of the process:

  • Determining the Data Serialization Format
  • Determining the Data Compression Format
  • Sending the Response
  • Decompressing the Response
  • Deserializing the Response

He also includes a section about caching the responses you get back from the server, an important step that can save you (and your users) some headaches and maybe even give a bit of a speed boost.

tagged: android webservice data serialization compression response

Link:

Justin Carmony's Blog:
PHP, Sessions, __sleep, and Exceptions
Mar 27, 2012 @ 17:25:02

Justin Carmony has a recent post to his blog about a problem he came across where his exception was being thrown with a line number of zero - cause for some investigation.

Today I ran into a problem where my PHP Application would throw this fatal error: "Fatal error: Exception thrown without a stack frame in Unknown on line 0". Which is so much fun, because it doesn’t have a line number, so I had no direction as to what exactly was causing the problem.

He found a blog post that helped him track down the issue that, as it turns out, with serializing objects into the session and an error in the __sleep method.

tagged: exception problem sleep serialization error handler

Link:

Project:
Aleksey Martynov's lexa-xml-serialization Tool for PHP 5.3
Sep 07, 2010 @ 17:40:37

Aleksey Martynov has submitted a project that can come in quite handy of you do a lot of work with XML in your application - a XML serialization tool for PHP 5.3 that lets you easily translate objects into valid XML.

lexa-xml-serialization is a lightweight library for serializing PHP objects to XML like it's done in .NET. My xml serializer requires that you mark serializable properties of your classes with doc-comment annotations. The properties are not required to be public. The lettercase of annotations doesn't matter. Whitespaces are not essential. Parameters are optional: type defaults to string, xmlName defaults to the property name. Parameter values must not be enclosed in quotes. Empty brackets may be omitted.

The page on the Google Code site gives some examples of it in use as well as as "first look" tutorial about building a large, more complex XML file. If you want to try it out, head over to the download page to grab the latest.

tagged: xml serialization object convert docblock comment

Link:

Cohesive Web:
PHP serialization or Json
May 24, 2010 @ 17:04:05

On the Cohesive Web blog there's a new post looking at storing complex data types like data structures or objects effectively.

Think of a situation where you are working with some array. Now there may be some situations where you need to store the array and retrieve it back. If you are familiar with OOPS concept then objects are another type which you may need to store and retrieve. Serialization is the process by which you can convert an object or data structure into a sequence of bits which can stored and retrieve back.

They suggest an interesting option for storing object information - converting it to JSON instead of just serializing it and storing it that way. After running a few tests on the method, they found using the json method a bit better/lighter than the serialized way (for their purposes).

tagged: serialization tutorial json object

Link:

Alexey Zakhlestin's Blog:
Syck 0.9.2
Nov 23, 2007 @ 15:14:00

Alexey Zakhlestin has released the latest version of his Syck tool - a "parser and emitter" of YAML documents.

I've just released syck for php 0.9.2 (a parser and emitter of YAML documents. If you don't know anything about YAML and why it is good: check my previous posts on the subject). A lot of new and tasty features.

Updates he mentions include:

  • stability and consistency fixes
  • enhancements with object-serialization and unserialization
  • loading of objects more class names
tagged: syck update version yaml fix serialization object syck update version yaml fix serialization object

Link:

Alexey Zakhlestin's Blog:
Syck 0.9.2
Nov 23, 2007 @ 15:14:00

Alexey Zakhlestin has released the latest version of his Syck tool - a "parser and emitter" of YAML documents.

I've just released syck for php 0.9.2 (a parser and emitter of YAML documents. If you don't know anything about YAML and why it is good: check my previous posts on the subject). A lot of new and tasty features.

Updates he mentions include:

  • stability and consistency fixes
  • enhancements with object-serialization and unserialization
  • loading of objects more class names
tagged: syck update version yaml fix serialization object syck update version yaml fix serialization object

Link:

Terry Chay's Blog:
serialization without pity
Mar 21, 2007 @ 17:02:00

In response to a post from the Stubbles blog, Terry Chay has posted some of his thoughts about the serialization solution presented in the other post.

Frank Kleine writes a PHP 5 framework called Stubbles. I have a long-standing view about frameworks that hasn't changed one bit. But instead of arguing about the Sysaphean task Frank is engaging in, I'll show what my approach is to one small component (while being a bit jealous that he can actually develop in PHP 5).

Frank's solution involves storing the objects in the session, serializing them first. The issue comes up when the class(es) the object needs aren't included into the page. Terry offers a different sort of solution - one also using __autoload, but using it combined with unserialize_callback_func.

Terry compares this with Frank's approach and notes that his method "closes off" the system from the very PHP functions that could make his life simpler (making a separate handling system). He also includes a method for doing the same when all you know is the class file's name (non-PEAR format).

tagged: serialization pity stubbles framework article response autoload unserializecallbackfunc serialization pity stubbles framework article response autoload unserializecallbackfunc

Link:

Terry Chay's Blog:
serialization without pity
Mar 21, 2007 @ 17:02:00

In response to a post from the Stubbles blog, Terry Chay has posted some of his thoughts about the serialization solution presented in the other post.

Frank Kleine writes a PHP 5 framework called Stubbles. I have a long-standing view about frameworks that hasn't changed one bit. But instead of arguing about the Sysaphean task Frank is engaging in, I'll show what my approach is to one small component (while being a bit jealous that he can actually develop in PHP 5).

Frank's solution involves storing the objects in the session, serializing them first. The issue comes up when the class(es) the object needs aren't included into the page. Terry offers a different sort of solution - one also using __autoload, but using it combined with unserialize_callback_func.

Terry compares this with Frank's approach and notes that his method "closes off" the system from the very PHP functions that could make his life simpler (making a separate handling system). He also includes a method for doing the same when all you know is the class file's name (non-PEAR format).

tagged: serialization pity stubbles framework article response autoload unserializecallbackfunc serialization pity stubbles framework article response autoload unserializecallbackfunc

Link:

DevShed:
Using Inheritance, Polymorphism and Serialization with PHP Classes
Aug 15, 2006 @ 14:02:43

Some concepts of object-oriented design are harder to figure out that others for a budding programmer. Thankfully, there's articles like this one from DevShed to help fill in some of the gaps. Specifically, they focus on inheritance, polymorphism, and serialization in your PHP classes.

If you are working with classes in PHP, you will sooner or later encounter inheritance, polymorphism, and serialization. The ability to use these three will help speed up your code writing. This article covers how to use them, and more.

First off, they look at inheritance and working with child classes before moving on to polymorphism (similar functionality, different objects), calling functions statically, and serializing objects to make passing them around much easier.

tagged: classes object oriented polymorphism inheritance serialization tutorial classes object oriented polymorphism inheritance serialization tutorial

Link:

DevShed:
Using Inheritance, Polymorphism and Serialization with PHP Classes
Aug 15, 2006 @ 14:02:43

Some concepts of object-oriented design are harder to figure out that others for a budding programmer. Thankfully, there's articles like this one from DevShed to help fill in some of the gaps. Specifically, they focus on inheritance, polymorphism, and serialization in your PHP classes.

If you are working with classes in PHP, you will sooner or later encounter inheritance, polymorphism, and serialization. The ability to use these three will help speed up your code writing. This article covers how to use them, and more.

First off, they look at inheritance and working with child classes before moving on to polymorphism (similar functionality, different objects), calling functions statically, and serializing objects to make passing them around much easier.

tagged: classes object oriented polymorphism inheritance serialization tutorial classes object oriented polymorphism inheritance serialization tutorial

Link:


Trending Topics: