This plugin provides support for CakePHP.
since 2010/07/16
CakePHP3 support is not provide in this plugin. Please use the following : cakephp3-netbeans
CakePHP project is not recognized automatically from NetBeans 8.0. Please check project properties > Framework > CakePHP > enabled
[*1] right-click in project node > CakePHP > (Run Command | Clear Cache | Install Plugins)
app/tmp is ignored with default. If you would like to avoid this, please, uncheck ignore tmp directory
option.
Your NetBeans Project needs to have the following trees.
CakePHP 1.3.x
myproject
├─nbproject
├─app
├─cake
├─plugins
├─vendors
├─...
CakePHP 2.x
myproject
├─nbproject
├─app
├─lib
│ └─Cake
├─plugins
├─vendors
├─...
NewProject (Ctrl + Shift + N) > PHP > PHP Application with Existing Source Please select your cakephp dir(e.g. /home/NetBeansProjects/myproject)
You can set app directory path from source directory. Project properties > Framework > CakePHP > Custom directory path > app
If you use multiple app directories:
// CakePHP 1
cakephp1.3
├─app
├─app2
├─app3
├─myapp
├─...
├─cake
├─plugins
├─vendors
├─...
// CakePHP 2
cakephp2.x
├─app
├─app2
├─app3
├─mycustom
├─...
├─lib
│ └─Cake
├─plugins
├─vendors
├─...
Use app directory as NetBeans project e.g. app1, app2, myapp, e.t.c.:
myproject(e.g. myapp)
├── nbproject
├── Config
├── Console
├── Controller
├── Lib
├── Locale
├── Model
├── Plugin
├── Test
├── Vendor
├── View
├── index.php
├── tmp
└── webroot
app
: "" (empty or ".")CakePHP Root
: "../"Please notice that Code Completion is not available. You have to add the cakephp core path to include path.
After settings, please close your project and reopen it.
.cake
is configuration file for plugins of editors and IDEs.
If your CakePHP project is not default directory structure, you should use it.
e.g. In case of your app/Model
directory name is app/MyModel
,
you have some Controller
directories (Controller(default), SecondController, ThirdController), e.t.c.
You can create it with Dotcake Plugin .
If you want to use it, please set its path to Project properties > Framework > CakePHP > .cake
Delete each files of app/tmp/cache/* directorys.
Settings: Tool > Option > PHP > CakePHP
Url is only zipball url.
Run Action: see [*1]
Plugin version numbers are not necessarily latest. Please try to check and edit them manually.
You need to connect the network.
Ctrl + Shift + N
)Select Unzip
or Unzip local file
or Composer
or git command
.
If you select Unzip
, also select CakePHP version.
If you want to unzip the local file, please set the option
(Tools > Options > PHP > CakePHP > New Project > Local file path
)
If you want to create a database.php file, please, check the Create database.php.
Also set the following automatically.
create a database, you can immediately start development in a local environment.
We can set default composer.json
on Options panel. We can use --empty
and app name settings when we create a project.
--empty
is used with bake project
. If app name is empty, app directory is source directory, otherwise it is created under the source directory.
Support for core components and helpers (default). Also support for classes in $uses, $components, $helpers.(also contain the alias)
// e.g.
public $uses('Comment', 'Member', 'User');
// $this->Comm [Ctrl + Space] => $this->Comment [Ctrl + Space]
public $components('Search.Prg', 'Foo');
// $this->P [Ctrl + Space] => $this->Prg-> [Ctrl + Space] => display methods and fields
public $helpers('Session', 'Html' => array('className' => 'MyHtml'));
// $this->Html-> [Ctrl + Space] => display MyHtmlHelper class methods and fields
$this->Html->image('[Ctrl + Space]');
// popup file and directory names in the webroot/img
$this->Html->image('subdir/[Ctrl + Space]');
// popup file and directory names in the webroot/img/subdir
// ...
$this->Html->image('/mydir/[Ctrl + Space]');
// if you want to use files or directories in the webroot directory,
// please, start with "/"
$this->Html->image('Debug[Ctrl + Space]');
$this->Html->image('DebugKit.[Ctrl + Space]');
// support for Plugin images (CakePHP 2.x)
If target file exists, image will be displayed on document window.
You can run code completion also css and script methods ($this->Html->css(), script()
) like the same as image method.
$this->Html->css('[Ctrl + Space]');
// popup file and directory names in the webroot/css
$this->Html->script('subdir/[Ctrl + Space]');
// popup file and directory names in the webroot/js/subdir
$this->Html->css('/mydir/[Ctrl + Space]');
$this->Html->script('PluginName.[Ctrl + Space]');
$this->element('[Ctrl + Space]');
// popup file names in the appdir/View/Elements/
$this->element('MyPlugin.[Ctrl + Space]');
// support for Plugin elements (CakePHP 2.x)
This is available in the following fields. This can also complete the plugin name. Please run code completion again(i.e. [Ctrl + Space]) after "PluginName.".
// e.g.
public $components = array('[Ctrl + Space]');
public $components = array('DebugKit.[Ctrl + Space]');
You can move from controller action to view file.
e.g.
class MainController extends AppController{
// ... something
public function index() {
// Right-click or shortcut here
}
}
If you use shortcut, register with Keymap.
When the view file doesn't exist, create the empty view file automatically if set as follows.
Check Auto create a view file when go to view action is run
at Right-click on project node > property > Framework > CakePHP
If you use the theme, set $theme to controller field.
Available code templates : Tools > Options > Editor > Code Templates > HTML/PHP
e.g.
App::uses('AppController', 'Controller');
$this->Html->
This feature is also available with code completion.
Similar to Go to view action.
You can go to specific files relate to a current file.
e.g. In case of current file is Controller, you can go to existing view, model, component, helper and test.
There are three ways.
Pattern : [Ctrl + Shift + G] [] (or [Ctrl + J] [])
Of course, if you don't like these shortcuts, you are able to change them in Options (KeyMap).
project properties > Frameworks > CakePHP Please uncheck the following if you would like to go to it soon (without popup) when candidate file is only one.
This action run the following.
Q. Why do you add this action?
A. I add in order to follow the CakePHP Coding Standars
You can go to the element file from view file.
Search the following element file directories:
e.g.
$this->element('sample');
Hold down Ctrl key and click on 'sample'.
If there is sample.ctp in the above directories, open the sample.ctp. Otherwise do nothing.
You can change debug level on popup list.
When you choose the CakePHP file node, you would find the cake icon and debug level number at the lower right of the window.
If you change debug level, click the icon. Then the popup is displayed. Please, select the debug level number.
Check default asset names. (e.g. css/cake.generic.css, img/cake.icon.png, ...)
Check whether favicon.ico is changed.
Support for only CakePHP2.x
Project-right-click > CakePHP > PHPUnit Test Init
Do settings for doing PHPUnit Test with NetBeans.
Create following files:
And set PHPUnit settings of Project properties:
If you run this action, you can test using fixture with NetBeans.
https://gist.github.com/2055307 (nojimage)
Alt
+ Insert
or Right-click on editor, select Insert Code
.
Dialog is displayed when you run Insert Code action. Please select what you want to use. And code like followings are inserted.
$helpers = array('Html', ..., 'PluignName.SomeHelper');
$componens = array('Session', ..., 'MyComponent');
$uses = array('Post');
$actsAs = array('Tree', ..., 'PluignName.SomeBehavior');
You have to add settings for each classes by yourself if you need it.
This provides support for only Core validations.(e.g. notEmpty, isUnique, e.t.c) At first, you have to write the following before you run this feature.
public $validate = array(
'fieldName' => array(
// please set caret to here
),
);
Please move caret to place which you want to insert, and run Insert Code action. Then, code like followings will be inserted:
// template
'validationName' => array(
'rule' => 'validationName',
'message' => 'validationNamemessage'
},
// template : has arguments(are not initialized)
'validationName' => array(
'rule' => array('validationName', validationName_arg1, validationName_arg2),
'message' => 'validationNamemessage'
},
Since message is focused, you can change it to your message.
Please push Enter
key after you change it. And you can move to next message.
If you want to move to previous message, please push Shift
+ Tab
.
Please see also https://github.com/junichi11/cakephp-netbeans/issues/12
You can run the action for controller.
right-click > CakePHP > Run Action
or Editor Toolbar > Cake icon > Run Action
public function index() {
// move the caret here
}
Currently, this is available for the simple situation.
Please also see the following: https://github.com/junichi11/cakephp-netbeans/issues/16
baserCMS is an open source CMS and powered by CakePHP Framework.
Common Development and Distribution License (CDDL) v1.0 and GNU General Public License (GPL) v2