Archive for the 'PHP' Category

CakePHP: Running bake.php on Windows command line

Aug 12, 2006 in PHP, CakePHP

I have been wondering why my bake.php is not working like it is suppose to be. After some debugging with the help of exit() and die(), I found out that PHP (v4.4.2) is not reading the arguments on the command line. After a quick google-ing, I found out that there’s a php.exe for CLI. It is different then the one on the PHP root directory. You can find out if the php.exe you are running from the command line is a PHP for CGI or PHP for CLI by: >php -v.

To run bake.php correctly on windows, you have to use PHP for CLI not PHP for CGI. On my system, PHP for CLI is residing in the PHP_ROOT\cli directory. So, what I did was renaming the php.exe in the CLI subdirectory to php-cli.exe, then add PHP_ROOT\cli into my PATH. Now, I can run bake.php with:

**>php-cli bake.php -h** this should display bake help file.

I hope the above information is helpful.

Free templates for CakePHP

Aug 10, 2006 in PHP, CakePHP

A blogger residing in Japan… maybe a Japanese, I dunno… converted Contented Designs templates into CakePHP Templates. Feel free to use those “open-source” design!

More here..

PHP can scale

Aug 10, 2006 in Software Engineering, PHP

I will keep this post short. I found a presentation about Flickr’s architecture from John Lim’s blog while google-ing for “smarty with yahoo ui”. John Lim btw, is the developer for ADOdb, a PHP database abstraction library…. and it is one of the BEST one out there IMHO. And I am proud that he is a Malaysian. =D



After looking at the 41 slides on Flickr’s architecture… it has made me rethink the way I design web applications. I used to normalize my database design all the way… (thx to uni lectures) but doing that would sacrifice performance as “JOIN” are expensive operations. I might wanna start exploring database session instead of using web server’s session. Replication sounds great as well. 1 master database server for insert/update/delete and a farm of replicated database servers for ’select’, since almost 50% of database transactions are select statements. Anyway, I am just repeating what is written in the presentation, so download and read about it yourself. ^_^



*p.s. but try not to over-engineer… a habit which I do often.

EasyEclipse - Free, open source, easy-to-use Eclipse distribution

Jul 13, 2006 in PHP, Java, Open Source, Free, Subversion

EasyEclipse Previously in this post, I mention about using Eclipse with PHPEclipise plug-in. Well, good news to those who are interested but find it too difficult to install the plugin. EasyEclipse is a Eclipse distribution with tested plugins and packages ready for you! There are a number of distribution available, for example… Mobile Java, Desktop Java, LAMP environment, PHP and so on. Go check it out! They even have the Subversion plugin installed!

The PHP distribution have very similar plugins as what I am using now on my desktop… the difference is I took hours to set it up.

Picking up the pieces

Jul 08, 2006 in Software Engineering, PHP

What is worst then reinventing the wheel? Correcting “SHIT” codes…. -_-”

I am doing this emergency development (or fixing) of a Social Network web application. It is written by someone irresponsible… very irresponsible. He was partnering with this veteran company to develop this project, then all the sudden he stop developing it and got himself out of the partnership and even DARE to request for the rest of the payment. He is already 2 weeks off the DEADLINE.

After examining his work, now I know why he call it quits. He developed a piece of crap. I might sound harsh but it is true. He uses outdated Template engine, and a very old version of ADOdb. The way he architect the application could never be able to scale and meet the requirements of a successful social network. So now I have to fix everything in less than a week…. during World Cup finals’ week!!! This is torturing!!!

Anyway, I have to fix this up. First off… by replacing the ADOdb with the latest stable version. It looks like a Malaysian developed this piece of high quality database abstraction library for PHP. :)

Drupal ebook, hosting

Jun 05, 2006 in PHP, Tips

Drupal Image It’s 4am and I just finish reading a couple of chapters on Drupal in this APress book with the title “Building Online Communities with Drupal, phpBB, and WordPress”. A big thanks goes to Trevor for helping me locate the ebook.

This ebook is perfect for me since I am working on Drupal, phpBBand WordPress, yup all 3! For the record, Patch IT Sdn Bhd offers managed hosting and customization for all three application. =)

So far the book is great for the Drupal section which I read. Although there’s alot of information available at Drupal.org, I still prefer reading a book to get my feet wet and then only search for particular stuff on the site or google. Yup, even with the almighty Internet… the ancient invention - “book” is still my preferred method of learning new stuff.

PHP Markdown integrated!

Jun 01, 2006 in PHP

I have to disabled rich text editor for WordPress after installing geSHi, so it takes a little more work to write a post. So here comes Markdown! Markdown is a plain text to html converter, basically it’s like… writing syntax or shortcut to produce html. But you will need some time to get use to the syntax.

symfony did it again and syntax highlighting

Jun 01, 2006 in PHP, Symfony Framework

Symfony, a PHP5 Framework did it again by launching another real-world application with all the goodie source code. This time they come out with Snipeet, an “open-source social code snippet repository” or so they call it. The other application which they come out with was the 2005 advent Calendar, a 24 days tutorial building the site askeet.

While exploring Snipeet, I came across something which I wanted to implement here, GeSHi - the Generic Syntax highlighter. As a blog mainly about software development, of course we will need a Syntax highlighter! But I will not be writing my own plugin for this. Next, my good friend “Google” lead me to a WordPress plugin call Simple Syntax Highlighter.

Ok, now to test it out with the standard “Hello World” thingy… and vola~~!

Error: Could not open helloworld.phps

pitAuth:User authentication for CakePHP

May 24, 2006 in PHP, CakePHP, Encryption

pitAuth is a user authentication implementation for CakePHP, ya ya… there are some implementations out there already.. like othAuth, and rdAuth. Although I do support the open source community, I got a company to grow. @_@ I also want to have a more secure implementation.

Drafted feature:

  • “salted” SHA1 encryption instead of MD5 (would probably use more resources than MD5)
  • User can be in one or more Group
  • Each user and group might have one or more permission
  • Integration with CakePHP ACL
  • Generate new password for password retrieval
  • Plugin-ready for LDAP and other method

I will continue to add once I figure them out. The comments on PHP Manual on SHA1 has some useful information on security and improving performance.

PHP full-text search engine

May 24, 2006 in PHP, Full-text Search Engine

After intensive research on full-text search engine for PHP, I found the following solutions if I want to use CakePHP as the main underlying framework.
Utilize Java Lucene by using a PHP JAVA Bridge

This is quite challenging. The performance seems promising, but it does look complicated. Basically we will have to develop the indexing with Java and process input/display results with PHP. Now… will I wanna do that?

Pros

  • You can use a unported Apache Lucene
  • Tons of resources on using Lucene
  • Can upgrade Lucene libraries and use it. Rather than waiting for the ported version to be fix

Cons

  • Complicated
  • Too many technologies to master

Zend Framework integration with CakePHP

The strong point of Zend Framework is the ported Apache Lucene, the zend_search_lucene library. That’s about the only thing I like about Zend Framework, that’s why I might wanna integrate this zend library into CakePHP, this tutorial about using zend lucene looks familiar enough.

Pros

  • Those who used Apache Lucene before will feel like home
  • Lucene IS the best Java full-text search engine out there

Cons

  • Works only in PHP5, CakePHP works on both PHP4 and PHP5. The integration will kill one of CakePHP’s strong point
  • Have to learn another framework. We had enough right?

MySQL full-text searching capabilities

MySQL has a built-in full text search feature. This article here has some information about it. But I would need to write MySQL statements rather than using CakePHP ActiveRecord pattern, and the application would be MySQL database-dependent.

Pros

  • Should be quite fast, since it is a native MySQL operation
  • Can be converted to a plugin for various framework

Cons

  • Will be lock down to MySQL
  • Building a search engine is not a fun task

Xapian using PHP-Binding

Xapian looks promising as well. I think the performance of Xapian should be quite good as it is programmed with C++. I can’t comment much on this. You guys might wanna check it out and probably help me out.

Solr

I just found this a minute ago. Solr is built based on Lucene by CNET Networks who donated the source code to Apache. The unqiue feature of Solr is the XML/HTTP APIs and it is actually a server! So you can have a Java application… a PHP application or any type of application which is capable of handling XML, all of those application can access Solr. This looks like a good solution, but I am a bit worried about the security of transfering XML between servers. I will keep an extra eye on this one.