Archive for category PHP

Upgrading to PHP 5.3..! – are you sure?

If you are planning to upgrade to PHP 5.3 from PHP 5.2.x then you must think twice before you really do it. There are few things you should take care of. Recently last week I tried upgrading one of the web-server to PHP 5.3 from PHP 5.2.9 and it was not a good idea which I came to know later on.

It is not only about deprecated functions which are creating Warnings or Notices but TCPDF library for generating PDF has created some wired problems due to which I have to roll back to the older version, as it was one of the crucial functionality of the application. It was not a planned version upgrade but it was a server migration and on the fly I tried upgrading PHP version also.

There are many functions and some of php.ini parameters which are deprecated, for complete list please refer http://www.php.net/manual/de/migration53.deprecated.php.

You can’t pass parameter while overriding “magic methods”; so if you ever had your __toString() method overridden with __toString($device = ‘SCREEN’) then it won’t work with PHP5.3. Other than that date_default_timezone() or similar timezone setup function also had some problems.

// This won't work with PHP5.3 and will work with 5.x
public function __tostring($device = "SCREEN")
{ ... }
 
// This will work with PHP5.3 and 5.x
public function __tostring()
{ ... }

So crux is if your applications are not ready for PHP5.3 it is not wise decision to upgrade and if you have to upgrade we should make sure to test whole application and all functionalities as with large development teams sometimes you never know who has used what all the time.

Using Zimbra LDAP Server Authentication with PHP

I wanted to provide our CRM users an alternate way of logging to the system using their Zimbra email authentication and there is a really easy way of doing it which I have figured out in little while with googling. Definitely PHP online help docs and Zimbra forums both came to help and found a correct options to use from Zimbra Forums which is powered by it's USERS.

Just make sure to enable php_ldap extension before you move further.

// Uncomment following line from php.ini
extension=php_ldap.dll

Following code snippet could be used to authenticate and find out whether provided Username and Password belongs to valid Zimbra User or not by authenticating it with Zimbra's LDAP (Light-weight Directory Access Protocol) server. So this way if you want you can provide your intranet/business application users an ability to use their Zimbra (mail/collaboration system) password to be used as an optional way to authenticate themselves. Read the rest of this entry »

Tags: , ,

When PHP Frameworks are going to stop PHP 4 support?

As of now we have many frameworks which are still supporting PHP 4.x. CakePHP and CodeIgniter are leading that troop. Now we have PHP 6 about to get ready for production and PHP 5.x is in it's mature stage since long while now with PHP 5.3 as the latest release. I am not against for support on 4.x version of PHP; may great developers/teams have developed awasom tools and application and they should be still usable without any modifications in their coding.

PHP 4.x Hosting:

So PHP 4.x support for hosting is fine and it's required to keep those applications running and being hosted without any maintenance saving efforts and time. So applications developed for PHP 4.x can run as long as they wish and till there are no equivalent forks of them available in PHP 5.x or newer version.

PHP 4.x for Development:

PHP 4.4.9 has been released as final release for PHP 4.x now and it has been announced as end of life for PHP 4.x now. So developing any project or framework by keeping PHP 4.x compatibility is not a good idea I believe. All projects or framework has to freeze their PHP 4.x versions and let only bug-fixes be made available for those versions and have new feature-set addition be on the fork which is only PHP 5.x. I think every project will have to come up with a date when they will join GoPHP5 rally. For example Symfony 1.2 and 1.3 (Symfony is a PHP 5 only MVC Framework) are specifically supporting PHP 5.2.4 or newer version only.

Basically for newer development it is better idea to use version which has longer future so that finally they don't need to write a fixes which allow those projects to continue working in both the environment. Which will save time on development, QA and maintanence all phases.

I am not against the PHP 4.x but it is a change which is eneviable and which has to happen in it's completeness sometime and change is for good. I am not sure how many of you agree with my thoughts but please share your thoughts on this subjects as comments for this post.

Tags: ,

PHP Text Encoding – Challenge..!

Before sometime I had a project where I am required to create a message digest to authenticate web-service call. Initially it looked simple but while trying on staging server it never authenticated properly. Basically it was a Surescripts web-service implementation where we have to strictly follow their protocols. Read the rest of this entry »

Tags: , ,

PHP 5.2.7 is released

This is good to hear that PHP 5.2.7 is released last week. PHP 5.3 alpha 3 is released as well at the same time. Actually this release has taken more than 6 months after it's last stable release of 5.2.6 version. But it's better later than never. I have come across some blogs archives indicating dull future of PHP in coming year, but this slow and steady progress confirms that PHP elephant is here to stay, and there are many other blogs out there which indicates that too.

This release is majorly bug-fix release consisting more than 100 fixes; you can see change log here.

Anyway I believe in this world where IT is mandatory to run your business and to hold the backbon; everyone wants it cheap and LAMP does that well..!

BTW Wampserver team is damn fast in building their packages and this time they came out with PHP 5.2.7 + Apache 2.2.10 + MySQL 5.1.30 just next day of PHP 5.2.7's release. So enthusiastic developers can get their hands on with latest of all 3 of them. Download Wampserver 2.0e here.

Tags:

Symfony 1.2 first Beta is out

First beta version of new symfony version 1.2 is out now. There is a long long list of What's New in Symfony 1.2 but some of them are:

  • Doctrine to be bundled with framewok with Propel.
  • Prototype and Scriptaculous as core Javascript plugins.
  • Enhanced Web Debug Toolbar.
  • Propel 1.3 upgrade.
  • Many improvements and new features in Forms.

The list goes long and you can catch up that on Symfony website or just download and install a fresh copy of symfony 1.2 to play with.

Tags: , ,

PHP – Downloading a File from Secure website (https) using CURL

Recently in one of my project I was suppose to download file from a secure website. Actually I have to set the scheduler job for downloading nightly builds/full files from the server and the files are placed on secure website.

Initially I tried that with file_get_contents function but it was just downloading 0KB file. Then it strike me that oh..! I can't use file_get_contents as it can't understand the HTTPS protocol here. So what could help me nothing else then our best friend CURL. file_get_contents and fopen kind of other functions works fine with any http web locations.

Here is the simple CURL file transfer function snippet which will copy file from any secure http location. Read the rest of this entry »

Tags: , , ,

Zend Framework 1.6 RC1 with WSDL AutoDiscovery

Zend Framework's new release 1.6 is in it's RC1 stage now. It has got many exiting features, including one of the much waited WSDL auto-generation using Zend_Soap_AutoDiscover class. It will automatically generate WSDL based on your class definition based on PHP Documentation.

I am not sure why it is taking long with PHP to have WSDL auto-generation feature? May be loose typing..!

Anyway current implementation of Zend's WSDL generation with Zend_Soap_AutoDiscover doesn't seems to be perfect. It is having issues with Complex Type. Although you can manually generate WSDL with the help of Zend_Soap_Wsdl.

When I tried with AutoDiscovery feature results were surprising for Complex Type, behavior of generator was weired. Let's hope that Zend will fix issues with this great feature before their final release. Documentation is also in it's building stage and needs more examples and better compilation. Download Zend Framework from here, and try with tar.gz, it looks like zip is not working for me (more than once) with current compilation due to some reason.

Previously I have used WSDL generator class from jool.nl, it was quite handy and easy to configure and uses Reflections to generate WSDL from PHP Docs just like Zend Framework.

Tags: , ,

PHP: Performance Improvement Tips

This post covers some performance improvement tips by showing merits or demerits of various coding practices in PHP. While developing small websites or projects which are not meant to be maintained for longer period of time it's okey it we don't care about all this performance improvement and so on. But while we are into the development of some product or project which are going to be maintained for longer period of time then it is required that we take care of small things from the beginning. Initially we may feel that benefits are not drastic but when we have large amount of user base then all small and minor things matters.

In PHP we have always so many ways to do things. During development of PHP as a language, developer community/team added up many functions and features (due to requests..!) in the language and some of them might be redundant, so we have sometimes many ways to solve one problem. Here sometimes due to not knowing what is the best way to solve the problem, we use the solution which we already know or we are more familiar with. Sometimes as a developer we create habit of doing something in particular way for always. Please read on to know whether you are already aware of this tips, which could improve performance of your php application. (Even if it is micro improvement it matters..!) Read the rest of this entry »

Tags: , ,

Symfony 1.1 RC1 Released

There are some great news for symphony lovers. Symfony 1.1 is now in it’s release candidate stage. At the same time the biggest news is that after Yahoo! Bookmarks now Yahoo! has chose symphony to rewrite Yahoo! Answers..! That sounds great that symfony is making it’s stand higher and higher by being chosen for developing enterprise level application. Yahoo! Answers is the 2nd ranked education & reference site on the web and is available in 26 markets and 12 languages.

Dustin Whittle from Yahoo! has presented a case study on redeveloping Y! Answers with symfony and Yahoo!’s decision for choosing symfony as their development. Download presentation Yahoo! Answers - The Symfony way..!

These are some of the great and most joyful moments for Team symfony, I would like to congratulate symfony team for their great work.

Tags: , ,