When working with API's and webservices JSON is becoming more and more the standard used for "packaging" data. When you are looking into how API's are sending back data to you it will become evident that JSON is winning over XML.
JavaScript Object Notation, is an open standard format that uses human-readable text to transmit data objects consisting of key:value pairs. It is used primarily to transmit data between a server and web application, as an alternative to XML.
Although originally derived from the JavaScript scripting language, JSON is a language-independent data format, and code for parsing and generating JSON data is readily available in a large variety of programming languages.
The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627 and ECMA-404. The official Internet media type for JSON is application/json. The JSON filename extension is .json.
Issue is that when working with JSON it is very easy to have a small mistake somewhere in your JSON file which will break you entire code or makes your code unresponsive during parsing. If you for example use the json_decode function in PHP and your JSON file is having an issue it will simply return NULL as the value of the variable you used in conjunction with the json_decode function. Some debugging can be done using json_last_error() however a good thing to do first is to check if you JSON file is correct formatted.
Thanks to the guys from arc90 lab you can make use of the JSONLint. JSONLint is an online JSON validator which you can also use under the MIT license and which can be downloaded from github.
The personal view on the IT world of Johan Louwers, specially focusing on Oracle technology, Linux and UNIX technology, programming languages and all kinds of nice and cool things happening in the IT world.
Showing posts with label php. Show all posts
Showing posts with label php. Show all posts
Sunday, November 10, 2013
Saturday, September 07, 2013
Debug PHP with Oracle DTrace
Most common users and most developers who every now and then develop an application will not be using Dtrace. however, people involved in building and debugging applications that run under Linux or Solaris and people who are responsible for tuning and optimizing performance of mission critical systems will most likely be using Dtrace or at least they should start understanding it and possibly start using it. Dtrace is a dynamic tracing framework developed by Sun Microsystems for troubleshooting kernel and application issues in real time.
Dtrace gives you the option to truley see what your application is doing and how your operating system kernel is handling stuff. A real view of what is happening can be very good when you are diving deep into debugging applications and issues with your servers.
In the past Dtrace has primarily be used for "server" based applications and not si much for scripting languages. A not well know fact is that Dtrace is also a part of the PHP language. David Soria Parra has merged the Dtrace functions into PHP from PHP version 5.4 and onwards. The original way of using PECL to incorporate Dtrace into PHP.
If you are serious about building PHP applications and serious about finding bottlenecks in your code and the way your PHP code is interacting with your kernel you should look into Dtrace for PHP. Chritoper Jones wrote an article back in 2012 named "Adding DTrace Probes to PHP extensions" and recently wrote an article named "DTrace with PHP update" which are both good starting points. You can find both on the Oracle website in the PHP and Oracle blog from Christopher Jones.
Dtrace gives you the option to truley see what your application is doing and how your operating system kernel is handling stuff. A real view of what is happening can be very good when you are diving deep into debugging applications and issues with your servers.
In the past Dtrace has primarily be used for "server" based applications and not si much for scripting languages. A not well know fact is that Dtrace is also a part of the PHP language. David Soria Parra has merged the Dtrace functions into PHP from PHP version 5.4 and onwards. The original way of using PECL to incorporate Dtrace into PHP.
If you are serious about building PHP applications and serious about finding bottlenecks in your code and the way your PHP code is interacting with your kernel you should look into Dtrace for PHP. Chritoper Jones wrote an article back in 2012 named "Adding DTrace Probes to PHP extensions" and recently wrote an article named "DTrace with PHP update" which are both good starting points. You can find both on the Oracle website in the PHP and Oracle blog from Christopher Jones.
Monday, August 11, 2008
Official Support For PHP 4 Ends

The end is near, PHP4 is at the end of the official support cycle. Newer versions have made sure that PHP4 will no longer be supported. However, there are so many systems that are depending on PHP4, coded by developers who have left the company for some time already. What will happen to all those unsupported code? No security fixes anymore to keep those systems clean and up to date?
No, PHP security expert Stefan Esser will continue to provide security patches for PHP4. To get security patches for PHP4 you will have to go in the future to the Suhosin website.
Tuesday, May 06, 2008
php token_get_all LifeType

If you do not have the token_get_all function available some pages in lifetype will show the following error:
[error] [client xxxxxxxxx] PHP Fatal error: Call to undefined function token_get_all() in /usr/home/www/xxxxxxxxxx /public_html/class/template/smarty/internals/core.write_compiled_include.php on line 45
One solution is to add the function token_get_all so LifeType will work as intended, this however will require a recompile of php. A more simple hack is to change core.write_compiled_include.php which can generally be found in $lifetype/class/template/smarty/internals/.
On line 39 you will find a statement that makes sure that the function will only work when your php version is higher than version 5.0.
$this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
Now we do not want to have this executed so we change the required version from 5.0 to 7.0 which is not the version we are currently running. By making the change we make sure that there is never a call to token_get_all and by this we solve the problem.
$this_varname = ((double)phpversion() >= 7.0) ? '_smarty' : 'this';
This however is a quick and dirty hack, a better way is to recompile PHP with the token_get_all function included.
Sunday, March 16, 2008
More Google YouTube API

Also on other places on the web you can find some good resources on how to use the YouTube API set. For example programmableweb.com is a good starter and you must read the information on the google code pages on the YouTube Data API.
Thursday, March 13, 2008
Google YouTube API

They released a JAVA API consisting of a set of Java classes and a PHP API. To use the PHP client library, you must be running PHP >= 5.1.4. You also need to be using Zend_Gdata >= 1.5RC2, which is distributed as part of the Zend Framework. To use the Java client library, you must be running Java 1.5. After downloading the client library, you'll find the classes you need to get started in the java/lib/gdata-client-1.0.jar and java/lib/gdata-youtube-1.0.jar files.
There are also some Player API’s which can be used, a Javascript API and a flash API. The complete information about the new API's can be found on the google code pages.

Sunday, November 11, 2007
SQL Server 2005 Driver for PHP

The SQL Server Driver for PHP Community Technology Preview (CTP) is designed to enable reliable, scalable integration with SQL Server for PHP applications deployed on the Windows platform. The Driver for PHP is a PHP 5 extension that allows the reading and writing of SQL Server data from within PHP scripts. It provides a procedural interface for accessing data in all Editions of SQL Server 2005 and SQL Server 2000 (including Express Edition), and makes use of PHP features, including PHP streams to read and write large objects.
MSDN channel 9 is running a video interview with some of the developers which you can view here below. You can find out more about the driver itself here
removed the embedded video because wmv embedding is not working for all platforms and browser equally right. You can view the video via this link
Wednesday, July 04, 2007
Developing PHP multi database applications.
When developing a website or web enabled solution in PHP most developers do consider the fact that there database might be migrated to a newer version, what most do not consider is that they have to migrate to a completely different database platform. This might sound strange to some as they are developing there application for a specific database platform. However, when you develop a application which can be used at several sites you might not always be able to rely on the same database. Or in cases you are building a opensource or commercial solution you users might not always want to work with the database you have in mind. You might be developing your code on a Oracle 10G database while your customer thinks a Oracle database is overkill and wants to use a MySQL or PostgreSQL database.
For those who are not familiar with the three tier architecture, this architecture is describing the situation where you have a client, application server and a infrastructure server. The client is in a PHP web enabled solution a customer running a web browser, the application server is running a webserver with the PHP engine enabled. The infrastructure server is running a database. In the picture below you will see that all tiers are represented by a different server (or client pc). What you normally will see in not so critical environments is that the applications server and the database server are running on the same hardware platform.
When planning to build a PHP solution you might want to think about this problem and might plan in advance. To prevent that you need to write code for every possible database platform you will need to have a SQL translating engine in the middle. Even SQL is quite a standard language there are quite some differences between the database vendors SQL implementation.
You might consider to write your own SQL translator however there is a good opensource solution which can help you with this problem. ADOdb is a database abstraction library for PHP and will give you support on MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, MS SQL, Foxpro, Access, ADO, Sybase, FrontBase, DB2, SAP DB, SQLite, Netezza, LDAP, and generic ODBC, ODBTP. This enables you to write a single code pack to connect to all those “infrastructure” tiers instead of writing code for all those platforms.
For those who are not familiar with the three tier architecture, this architecture is describing the situation where you have a client, application server and a infrastructure server. The client is in a PHP web enabled solution a customer running a web browser, the application server is running a webserver with the PHP engine enabled. The infrastructure server is running a database. In the picture below you will see that all tiers are represented by a different server (or client pc). What you normally will see in not so critical environments is that the applications server and the database server are running on the same hardware platform.

You might consider to write your own SQL translator however there is a good opensource solution which can help you with this problem. ADOdb is a database abstraction library for PHP and will give you support on MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, MS SQL, Foxpro, Access, ADO, Sybase, FrontBase, DB2, SAP DB, SQLite, Netezza, LDAP, and generic ODBC, ODBTP. This enables you to write a single code pack to connect to all those “infrastructure” tiers instead of writing code for all those platforms.

Using the solution as shown above will prevent you from having the situation as shown here that you have to develop and maintain a large number of releases. Even do your developers will have to learn to adopt a new way of coding it will in the long run pay of when you decide to migrate to a different database platform or when you are working on a solution you will be distributing to customers. When you are developing

Subscribe to:
Posts (Atom)