PHP Application Development with NetBeans

I’m huge fan of NetBeans IDE for PHP based application development. Though I’m fully comfortable writing codes in text editors developed in mediavel ages :p, I’ve seen how IDEs like NetBeans let you concern about your application problem only while they take care of project management, code refactoring, syntax highlighting, versioning, code completion and any other features.

However, we can get most out of IDE (and anything) if we knew its usages very well. NetBeans were missing such manuals until recently a guide is written by PHP developer M A Hossain Tonu. The title of the book is PHP Application Development with NetBeans which is published by Packt Publishing, U.K.

Continue reading →

How I have solved the “The plugin generated xxxx characters of unexpected output during activation” problem

Recently this problem troubled me a lot. All time I try to activate my plugin, I get the following error:

The plugin generated 1186 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

After several attempts of debugging, I failed to understand why it is coming. The mysterious thing was that, this error was not coming for all WordPress installations!

Today, I decided to read the core files those are responsible for activating and/or deactivating the plugins. When I was reading wp-admin/includes/plugin.php, I saw a action hook ‘activated_plugin’ is available just before throwing the error. I believed, if I monitor what is happening here, I can know the reason of the error. So I wrote a small function to save the errors like:

Continue reading →

I’ve installed Ubuntu on my Macbook Pro 7.1

Well, since buying the Macbook Pro, I was trying to install my most favorite operating system (Ubuntu/LinuxMint). I have failed with LinuxMint and other Ubuntu. However, this manual helped meto get Ubuntu Lucid Lynx installed on my Macbook Pro.

Before installation, I run Ubuntu live. After I’ve confirmed that basic things are working, I have started installation process. The installation was seamless though I was worried about the boot loader. Because I already have rEFIt installed. So, I was not sure if grub will overwrite it or not but it didn’t!. However, I am still wondering, as grub is loaded after I select Linux from rEFIt, will it work if I remove rEFIt? The grub is showing both Ubuntu and Mac Os. Continue reading →

Passing filename arguments to PHP from shell and space issue…

Today, while working with a project to import thousands of articles from text files to wordpress,  I had faced a trouble while I am executing a shell script to iterate through all text files and call a PHP script with sending the filename as argument. The PHP script would then process the file as our requirement. The shell script looked like:

for i in `find . -type f -name '*.txt'`;

do

php import_posts.php $i

done

Here, $i would be the filename and it is passed to PHP script for processing. But the problem is that, when the filename (including directory name) consists any whitespace in its name, the script would broken. For example, some files path looked like
/home/user/articles/Internet Business/Web Hosting/how_to_start_your_company.txt

Here, notice the space after Internet and Web. The shell script was breaking just after Internet. It was sending /home/user/articles/Internet as argument to PHP script and obviously PHP script was failed to find this file.

After searching a lot, finally I found a solution.

It was really simple. I am quoting from his blog:

If none of your files or folders have spaces in their names, then this isn’t a problem, but that is increasingly unlikely nowadays.  If your songs do have spaces in their filenames, then the solution is to change how the shell splits that output.  This is controlled by the variable $IFS, which is set to spaces, tabs, and newlines by default.  We’d like it set to just newlines, so we do:

So, here is the solution. I just put the following line at the top of my shell script.

export IFS=$'\n'

After that everything is fine. The script is running exactly how I intended it to run.

Thanks for Anthony for his solution.