Showing posts with label framework. Show all posts
Showing posts with label framework. Show all posts

Sunday, October 18, 2009

xampp / lampp: upgrade PHPUnit in lampp 1.7.1

The default PHPUnit that ships with lampp 1.7.1 is not suited for use with Zend Framework 1.9. The reason is that the PHPUnit version in lampp is to low. So it is necessary to upgrade it using pear. However, before it can be done, pear version that comes with lampp 1.7.1 needs to be also upgraded. The pear executable is in /opt/lampp/bin so I went to this folder.

First PHPUnit channel must be added sudo ./pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded


Then pear chanels can be updated sudo ./pear update-channels

Then we can try to install PHPUnit:sudo ./pear install phpunit/PHPUnit
phpunit/PHPUnit requires PEAR Installer (version >= 1.8.1), installed version is 1.7.1
phpunit/PHPUnit requires package "pear/Image_GraphViz" (version >= 1.2.1), installed version is 1.1.0
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5)
No valid packages found
install failed


To upgrade pear I used sudo ./pear upgrade PEAR To check if upgrade was successful I used ./pear -V
PEAR Version: 1.9.0
PHP Version: 5.2.9
Zend Engine Version: 2.2.0
Running on: Linux arch 2.6.31-ARCH #1 SMP PREEMPT Tue Oct 13 13:36:23 CEST 2009 i686


Before PHPUnit can be upgraded, pear/Image_GraphViz package must be upgraded first. So sudo ./pear upgrade pear/Image_GraphViz
downloading Image_GraphViz-1.2.1.tgz ...
Starting to download Image_GraphViz-1.2.1.tgz (4,872 bytes)
.....done: 4,872 bytes
upgrade ok: channel://pear.php.net/Image_GraphViz-1.2.1

and install PHPUnit ./pear install -a phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.4.1.tgz ...
Starting to download PHPUnit-3.4.1.tgz (326,659 bytes)
...................................................................done: 326,659 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.4.1

After this, when I could use PHPUnit with Zend Framework as described in a tutorial here.

Wednesday, October 07, 2009

Xampp: SQLSTATE[HY000] [2002] Invalid argument

I'm currently developing a web application using Zend Framework 1.9.x. For this purpose I used Xampp for linux (i.e. lampp 1.7.2). Most of the time I was using arch linux with xampp 1.7.2 and there was no problem. Then I changed my os to Ubuntu 9.04 and I installed the same xampp 1.7.2. Interestingly, when I wanted to run my application under Ubuntu I got an errorMessage: SQLSTATE[HY000] [2002] Invalid argumentAfter googling I found that the reason was that in my php.ini (i.e. for xampp it is /opt/lampp/etc/php.ini) the variable pdo_mysql.default_socket was not set: Therefore I set it to /opt/lampp/var/mysql/mysql.sockOf course, I also had to restart Xamppsudo /opt/lampp/lampp restartIt is interesting why Xampp 1.7.2 worked under Arch Linux, but it did not work under Ubuntu 9.04?

Sunday, September 27, 2009

TOP PHP frameworks in terms of number of books published on a given framework

To begin with, I would like to say that I'm not new to PHP 4 and 5, but I would not call myself an expert. The reason is that for a few years now, PHP and web applications are things that I do only in my spare time. I also haven't used all the PHP frameworks, nor I'm the expert in any of them. I'm basically looking for a framework that is worth looking into and which would save me a time, as I don't want to spend much time on weekends coding e.g. only user authorization or registration form validation. So far, I did some small jobs using Prado, CakePHP and now I'm starting to learn Zend Framework. I also heard lots of good about CodeIgniter and Symfony. Since, I couldn't learn all of them, I just wanted to find some way of determining which of them seems to be the most popular. I decided to check how many books on a given framework are available in amazon.com?

I chose this criterion because for a person that wants to learn a framework, examples along with explanation can be valuable. Apart from official tutorials, quick start guides and reference manuals, that are available on the websites of the frameworks, books can provide good introduction along with example applications. Additionally, a number of books, also shows to some extend, how popular a given framework is. I would imaging that not many authors would write books about unpopular frameworks. Off course, there are many other possible criteria that can be used to rank or compare PHP frameworks, such as documentation, community support, performance, fast availability of updates etc., but I think that the number of books somehow translates to the the popularity of a framework.

Method of comparison

I went to amazon.com and I performed advanced searches for books on a given framework written in English and published after 2007. A year 2007 was chosen because books older than two years may contain highly outdated information. A framework name was a keyword. Than, the number of books found was counted.

En example of a search criteria used is given below:

Results

The results are as follows:
Zend Framework - 10 books (see the books)
Symfony - 9 books (see the books)
CakePHP - 3 books (see the books)
CodeIgniter - 2 book (see the books)
Prado - 0 books (see the books)

My personal opinion

From my perspective, the experience that I had with Prado (I used v. 3.1.4) was the worst one, although it's concept was interesting. I found it difficult to learn and use, because the documentation was sparse, there were not many tutorials, and even if I was wiling to invest some money and buy a book about it, I could not find any books about it.

After Prado I tried CakePHP (I was using v. 1.2). I found it very good, easy to learn and fast to use, as long as I adhered to all the naming conventions. Especially, I liked the ORM (Object-Relational Mapping) which was very useful and saved me a lot of time. The problem I had with it, was that it uses PHP 4, which already has been discontinued. Off course, sooner or later CakePHP will move to PHP 5, but I wanted to use a PHP 5. I think it would be better to use something in PHP 5, rather than something that is developed in a version of language that is already not supported. Off course, CakePHP runs smoothly on PHP 5. It is only CakePHP's core that does not use features of PHP 5. Additionally, I wanted to have more freedom when programming, and CakePHP does not allow for much of it due to it's "convention over configuration paradigm". But this is a price that you pay in CakePHP.

At the moment I'm learning Zend Framework v1.9 which is build using PHP 5. For now, I can say that it is definitely more difficult to learn at the beginning. The biggest issue that I had at the beginning, and still have but to a lesser extend, is a bootstrap class, which is difficult to understand. It really took me a long time to begin to understand how to use it at the simplest level. However, what I like is, that Zend Framework is less rigid than CakePHP, it uses PHP 5, and it has a vast number of tools (e.g. for working with PDF files or captcha) that CakePHP does not have.

I don't have experience with Symfony and CodeIgniter, so I cannot say anything apart from what I read in the Internet. CodeIgniter is considered to be faster than CakePHP and just like CakePHP, it is written for PHP 4, whereas Symfony is for PHP 5 only.

In conclusion, it seems that when you look only at the number of books on a given framework, Zend Framework is the winner with eight books. At the moment, I'm trying to get to know it, hopping that it will not be a waste of time. It must be remembered though, that there are many other criteria that can be used to compare PHP frameworks. However the final decision which framework to choose, if any, should be based on the specific needs of a project that we want to developed.

Tuesday, January 13, 2009

Prado framework: problems running demo applications

PRADO is a component-based and event-driven programming framework for developing web applications in PHP5. Beginners wanting to learn Prado may have problems when they want to run demo applications on their own server. Some demos simply don't work. Particular, I had problems on xampp 1.7 for Windows with AJAX Chat, address-book and northwind-db demos. The problem is that they use sqlite3 database and they require pdo_sqlite and php_pdo_sqlite PHP extensions. However, the PHP in xampp 1.7 for Windows(PHP 5.2.8) a comes with these extensions for only sqlite2, not sqlite3!. For that reason when I tried to run e.g. AJAX Chat demo I got the "DbConnection failed to establish DB connection: could not find drive" error:
The solution to this problem was, at least for me, to convert sqlite3 databases of these demos to sqlite2.

AJAX Chat demo

The online example of this demo is here. As previously indicated, when I wanted to use the demo I was greeted with DbConnection error. This indicates that there is some problem with database connections. AJAX Chat demo requires pdo_sqlite extensions. So first thing that I did was to check if my PHP has such extensions. Before proceeding I made sure that these extensions were enabled in php.ini or php5.ini. To check if I have these extensions I used <?PHP phpinfo();?>. These resulted, among other things, with the following:This cleary shows that my pdo_sqlite driver is sqlite2. For that reason I converted the chat.db database of the AJAX Chat demo from sqlite3 to sqlite2 as follows:sqlite3 chat.db .dump | sqlite chat2.dbNext, in application.xml I made the following change from to
Following these changes the AJAX Chat demo finally worked:

Address-book demo

Online demo is here. The problem with this demo was the same as with the AJAX Chat demo, i.e. sqlite database. Since the demo uses Flex the error message was little different:To make it work, I converted the demo's sqlite3 database to sqlite2 database as follows:sqlite3 sqlite.db .dump | sqlite sqlite2.db. Next application.xml was modified as before and the demo worked:

northwind-db demo

The problem with this demo is the same as before. However, this time converting sqlite3 database to sqlite2 database resulted in errors. In another worlds, I could not convert the demo's database. The reason was that the demo's database is much more complicated than that of address-book and chat demos, and sqlite2 returned syntex errors when dumping. At the moment I'm still analyzing AJAX Chat demo, so northwind-db demo is far ahead. When and if I get to it, I try to find some solution this problem.

Download of chat2.db and sqlite2.db

The two sqlite database created are here.

Sunday, January 11, 2009

oMedia cms: adding suggestions to the search panel

oMedia is a Polish cms that is used for websites that provide image and movie files (something ala YouTube). Although it has many useful functions, performing a search for a file on the websites using the cms is not straight forward. The reason is that the search input filed does not provide suggestion while the users writes the query. Hence, I looked into the code of the cms and I modified it. This modifications required changing two files: searchFile.page and searchFile.php. Since oMedia is build on top of Prado framework, it was necessary to change TTextBox component in searchFile.page into TAutoComplete component and modify corresponding searchFile.php.
The modified two files can be downloaded from here. Therefore, to use the files it is necessary to substitute the two files on one's server (there are located in protected/panels/). Of course be sure to make copy of the original files before substitution. Additionally if the original files had already been modified, the two files must be modified manually.