After the previous article regarding the power of NetBeans, today we will talk abit about integrating NetBeans with CakePHP.
Basically our problem with NetBeans occurs when we want code competition in our controller but we have model-based methods and properties. Also, if we want Cake’s functions and properties also then the same problem arrises.Lets image our [...]
After the previous article regarding the power of NetBeans, today we will talk abit about integrating NetBeans with CakePHP.
Basically our problem with NetBeans occurs when we want code competition in our controller but we have model-based methods and properties. Also, if we want Cake’s functions and properties also then the same problem arrises.Lets image our situation:
We have a model named Article.
We also have the controller for this model, named ArticlesController which we will use to find all articles in our database.
Article->find("all");
$this->set("articles",$articles);
}
}
?>
Normally in this case, when we are typing “$this->Article->” we want to have all the methods and properties of Article Model and parent AppModel but NetBeans is not showing us this.
The solution to this is actully easier then expected:
Just add before your class, in the documentation area of the file, the following code:
/**
* @property Article $Article
*/
Article->find("all");
$this->set("articles",$articles);
}
}
?>
We also have the controller for this model, named ArticlesController which we will use to find all articles in our database.
This can also be done to help you with belongsTo model propery. You can have an Article belong to a User and add the appropriate @property and then get the methods from the User model.
To get the methods and properties of Cake’s core, then just right-click on the project, go to PHP Include Path and add your cake-folder. Now you also should see all the build-in-functions and properties.
As you can see, its piece of cake!





