23.01.09

Netbeans revisited: Code Completion for Code-igniter

- PHP -

Some software you like, you start working with it, and you feel like it’s made for you. Everyday you discover a little bit more of all the hidden powers. That’s the good thing about open source, there is so much power that has yet to be discovered. Most commercial software claim a lot of features in their marketing brochures and disappoint enormously in the end when you start working.

Netbeans 6.5 is good software, out of the box it offers code completion and validation for php, html, css, javascript including jquery, mootools etc.

Code Igniter is a rapid development framework for  PHP, it’s a flexible MVC-like system. Netbeans let you easily implements CodeIgniter powers, by offering code completion for CodeIgniter’s native Active record classes, libraries and helpers functions.

You need to set it up though, and here we will explain how:

The first step is only neccesary if you have moved the system folder out of the Netbeans project source folder that contains the application folder, in case of a multi site set up or something.

Add the CodeIgniter System folder to the Netbeans Global Include Path:

Tools>Options>PHP>Add folder to  Global Include Path

This will give code completion for the helper functions and some more, but not for the Active record or database functions in a controller.

$this->db->...

To achieve more power, add this to your controller:
/**
* @property CI_Loader $load
* @property CI_Form_validation $form_validation
* @property CI_Input $input
* @property CI_Email $email
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
*/

class Stylist extends Controller

Now you can type
$this->db->...
or
$this->dbforge->...
And you will get all available functions offered. Wow!

To make it really easy, add this to Tools->Options->Editor->Code Templates

    1. New -> abbreviation: db
    2. Expanded text: `$this->db->`
    1. New -> abbreviation: `codei`
    2. Expanded text: `

      /**
      * @property CI_Loader $load
      * @property CI_Form_validation $form_validation
      * @property CI_Input $input
      * @property CI_Email $email
      * @property CI_DB_active_record $db
      * @property CI_DB_forge $dbforge
      */

Now you can easily insert the Codeigniter code just above your controller, by typing `codei` and TAB
or db TAB for $this->db->

That rocks, doesn`t it.

See also here and here

09.12.08

Netbeans IDE – a new star(t) for PHP developers

- MySQL, PHP -

Recently Sun Microsystems updated there Netbeans branch of Integrated Development Environment (IDE) software to version 6.5 and introduced native support for PHP for the first time. Historically Netbeans has been first choice for JAVA-decelopers,  but now made the move to the broad pool of PHP developers. How stiff is the competition Eclipse PDT or PHP-Eclipse, the other main open-source free IDE’S, are facing?

Main features of NetBeans:

  • Strong integration with PHP as realtime syntax checking, a PHPDoc implementation, code-autocompletion, which also integrates with used defined classes.
  • Version subcontrol: NetBeans offers support for Subversion, Mercurial en CVS out of the box.
  • Database manipulation tools NetBeans offers native access to  MySQL databasesto create tables, update records etc. No need for phpMyAdmin, although ceretain tasks are faster done with the old favorite management tool.
  • CSS and Javascript integration. Offers Javascript debugging and native support for the prototype, DOJO, MOOTOOLS, and JQUERY libraries.

New features as support for SFTP and frameworks like Drupal or Symfony are coming very soon.

First impression is good: intuitive, reasonable speed and feature rich. CSS, HTML and MYSQL support is better than in Eclipse, although Aptana plugins can help.

Try it out yourself:
Netbeans

21.09.08

The end of PHP 4

- PHP -

On the magical date 8-8-2008 PHP 4.4.9 was released, the absolutely last release in the PHP4 branche. PHP 4.4.9 has some important security fixes:

  • Updated PCRE to version 7.7.
  • Fixed overflow in memnstr().
  • Fixed crash in imageloadfont when an invalid font is given.
  • Fixed open_basedir handling issue in the curl extension.
  • Fixed mbstring.func_overload set in .htaccess becomes global.

Support for PHP4 has now officially ended.

12.04.08

Another php bug?

- Apache, PHP -

Tonight I had trouble with parsing url’s.

I wanted  to create some SEO-friendly url’s for a new site and the PATH_INFO server variable is a good base for it.

My url:

site/productname/camera

It’s easy to parse the url to segments with an explode on “/”

But I had a specific url that caused me troubles:

site/productname/cameraz.

Strangely  the  trailing dot disappeared:

echo $_SERVER['PATH_INFO']
site/productname/cameraz

while

echo $_SERVER['REQUEST_URL']
site/productname/cameraz.

That’s weird. I never saw those differences before.

I tried it on an old server with php 5.1.2. And NO difference there.

Somehow a bug entered in php 5.2.5 that deletes a trailing dot in $_SERVER[‘PATH_INFO’].

Be aware!

Of course it can also be caused in interaction with the apache-server.

28.11.07

PHP memory leak

- PHP, Uncategorized -

Consider an RSS feed read in as an SimpleXMLobject $rss.

What’s the difference between:

foreach ($rss->channel as $channel) {
...
}

and
$foo = $rss->channel;
foreach ($foo as $channel) {
...
}

Not much you would say, the first code example is shorter and more to the point. However when putting the scripts to work, (with a big rss file) we’ll soon see the difference.

Memory problem and a growing swap file

After a while the former example is causing a lot of disk activity and you will see your swap file grow and grow, at my computer it reached the maximum of 4 GB and off course it took ages for the script to finish.

And all that while the maximum memory usage for a script is set to 24MB in php.ini. Should run in a 1G computer you would say.
Well example 2 does but example 1 does not!

Is seems that iterating over an object-property in a foreach loop is troubled by a memory leak.

Solution

Example 2 is the workaround!

Conclusion

PHP 5.1 until 5.2 seem to suffer from this memory leak.

Categories
Archives
Links