Archive for the ‘PHP’ Category

PHP 5.2.9 released

Friday, February 27th, 2009

The PHP development team would like to announce the immediate availability of PHP 5.2.9.

This release focuses on improving the stability of the PHP 5.2.x branch with over 50 bug fixes, several of which are security related. All users of PHP are encouraged to upgrade to this release.

Security Enhancements and Fixes in PHP 5.2.9:

  • Fixed security issue in imagerotate(), background colour isn’t validated correctly with a non truecolour image. Reported by Hamid Ebadi, APA Laboratory (Fixes CVE-2008-5498). (Scott)
  • Fixed a crash on extract in zip when files or directories entry names contain a relative path. (Pierre)
  • Fixed explode() behavior with empty string to respect negative limit. (Shire)
  • Fixed a segfault when malformed string is passed to json_decode(). (Scott)

Further details about the PHP 5.2.9 can be found in the release announcement for 5.2.9, the full list of changes is available in the ChangeLog for PHP 5.
Read more here

Netbeans: Code Completion for the Kohana Framework

Tuesday, January 27th, 2009

In some earlier posts I’ve described ways to get Netbeans code completion working for CodeIgniter. In this post I will show you how to do the same for Kohana.

Kohana is originally a PHP-5 only fork of CodeIgniter, but it has developed into much more. Now all code has been rewritten, so only the framework in concept is based on CodeIgniter. It has nice ORM, AUTH and Cache modules.

It’s easy to convert and actually I prefer Kohana, it’s more intuitive and extensible. The only drawback: Kohana needs PHP 5.2+, where CI can be used with PHP 4.

Kohana uses the PHP class autoload feature, no need to include class files manually, PHP will lookup the file on the included path automatically at the moment the class is mentioned.
So when you write.
$this->db = New Database
The Database class declaration file will be loaded by PHP automatically. This way of lading classes is also understandable for the auto completion parser of Netbeans.

This is in contrast to CodeIgniter, because there classes are loaded like:
$this->load->library('validation')

To achieve code completion for CodeIgniter in Netbeans we have to manually insert comments to help the auto completion parser map properties to classes:
* @property CI_DB_active_record $db

That’s not the case in Kohana, but there is another problem. Kohana uses Class suffixes. The classes are declared like Database_Core, but called like Database (without the _Core).
To evade that we grap to the netbeans_ci_code_autocompletion helper file trick. But here we don’t write the property in comments, we simple do this:
Class Database extends Database_Core{}
etc

You can see the discussion on which this post is based in the Kohana forum. There is even a script that will generate the file automatically, so it will do extensions aswell. Works for Zend, Netbeans and Eclipse.

You can find the script here:
http://www.mapledesign.co.uk/code/kohana-zend-autocomplete/
There is a nasty flaw though on the website, they mixed up names. The script should be activated by:
http://yoursite/zend_ide
And it will create a zend_autocomplete.php file in the cache directory. You can move that to the nbproject folder if you want.

Netbeans revisited: Code Completion for Code-igniter II

Tuesday, January 27th, 2009

In an earlier post I described a way to achieve PHP code completion in Netbeans for the CodeIgniter framework. That way consisted of inserting property comments – which functioned as a helper for Netbeans to interprete the use – in every user application controller. This post will describe an even easier way, but first some comments about the earlier post.

I showed some ways to automate the inserting of the comments, although writing phpDocumentor comments in Netbeans is supported natively. Just type /** and completion will be available like explained here.

It’s a good custom to write comments in phpDoc style, it will help users to understand your coding, and it will offer an extremely easy way to publish documentation about your programs. Read here more about phpDOC.

On more remark, I wrote to include the CodeIgniter path in the Netbeans Global Include Path, it’s definitely better to do it on a project basis, so include it in the PHP Include Path in the Project Properties. Otherwise you will have CodeIgniter completion on projects that don’t use CI. 🙂

Now were getting to the core of this post. Probably the easiest way to achieve code completion is to put a file in the source path of Netbeans, but out of the CodeIgniter application or systems paths, let’s say a file called `netbeans_ci_code_completion.php`, but you can give it any name you want.

Make a text file with this content:
< ? /** * @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 * @property CI_Table $table * @property CI_Session $session * @property CI_FTP $ftp * .... */ Class Controller { } ?>

It doens’t matter how you call it, as long it has a php extension and is seen by Netbeans but not CodeIgniter. You can save it in a folder called temp, or even in the nbproject (netbeans project folder) folder. I worked for me, and I’ve haven’t noticed any drawbacks yet.

For most of my projects I have this project folder structure:

/application
/error
/images
/nbproject
/scripts
/styles
index.php
.htaccess

Putting it in the nbproject folder has the advantage that the file will not by copied to the server automatically, because that folder is already marked to be excluded in the synchronization settings.

Netbeans revisited: Code Completion for Code-igniter

Friday, January 23rd, 2009

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

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

Tuesday, December 9th, 2008

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

Your are browsing
the Archives of My Beloved PHP in the 'PHP' Category.
Categories
Archives
Links