Skip to content

Latest commit

 

History

History
287 lines (224 loc) · 9.65 KB

README.md

File metadata and controls

287 lines (224 loc) · 9.65 KB

sublime-cakephp-find

You can find out file and open easily.

Requirements

  • Sublime Text 2.x
  • CakePHP ver.1.3.x or ver.2.x

Installation

OSX

$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
$ git clone git://github.com/gold1/sublime-cakephp-find.git

Linux (Ubuntu like distros)

$ cd ~/.config/sublime-text-2/Packages/
$ git clone git://github.com/gold1/sublime-cakephp-find.git

Windows 7:

Copy the directory to: "C:\Users\<username>\AppData\Roaming\Sublime Text 2\Packages"

Windows XP:

Copy the directory to: "C:\Documents and Settings\<username>\Application Data\Sublime Text 2\Packages"

Setup (Version >= 0.8.64)

App::build

It's possible to search for the folder designated in App::build (only Model, Behavior, Datasource, Controller, Component, Auth, Auth, Helper, Lib, Vendor).

  • Sample
C:\www\html\cakephp\app\   : app
C:\www\mylib\cake2\Model\***.php  : Model class in directory
App::build(array(
    'Lib' => array('../../../mylib/cake2/Model/'),
));

Write on C:\www\html\cakephp\app\.cake

{"build_path":{"libs":"..\/..\/..\/mylib\/cake2\/Model\/"}}
Movement of a core folder

If directory "lib/Cake" was not placed in default path, you can set the new path in Sublime settings:

  • Sample
C:\www\html\cakephp\app\         : app
C:\www\cakephp\2.3.9\lib\Cake\   : cake

Write on C:\www\html\cakephp\app\.cake

{"cake":"C:/www/html/cakephp/2.3.9/lib/Cake/"}

or

{"cake":"../../../cakephp/2.3.9/lib/Cake/"}

Setup (Version <= 0.8.61)

If directory "lib/Cake" was not placed in default path, you can set the new path in Sublime settings:

  • Sample
/home/www/html/cakephp/app/         : app
              /other_cakephp/app/   : app
         /cakephp/2.3.9/lib/Cake/   : cake

Write on /Sublime Text 2/Packages/User/Preferences.sublime-settings

    "sublime_cakephp_find":
    {
        "project_path":
        [
            {
                "app": "/home/www/html/cakephp/app/",
                "cake": "/home/www/cakephp/2.3.9/lib/Cake/"
            },
            {
                "app": "/home/www/html/other_cakephp/app/",
                "cake": "/home/www/cakephp/2.3.9/lib/Cake/"
            }
        ]
    }

Switch Command

It changes to a corresponding file.

Command File Function
ctrl + shift + c, c controller cake_switch_to_controller
ctrl + shift + c, v view cake_switch_to_view
ctrl + shift + c, m model cake_switch_to_model
ctrl + shift + c, t test cake_switch_to_test

Example

<?php
//app/Controller/SamplesController.php
class SamplesController extends Controller {

                       // - 
    function index() { // | 
                       // | : command(V) -> app/View/Samples/index.ctp
                       // | 
    }                  // | 
                       // - 

    // : command(M) -> app/Model/Sample.php

    // : command(T) -> app/Test/Case/Controller/SamplesControllerTest.php
?>
<?php
//app/View/Samples/index.ctp

// : command(C) -> app/Controller/SamplesController.php : function index()
?>

Open directory

You can choose file from panel.

Command Directory Function
ctrl + shift + c, ctrl + d current directory cake_show_directory_list
ctrl + shift + c, ctrl + c controller cake_show_controller_list
ctrl + shift + c, ctrl + m model cake_show_model_list
ctrl + shift + c, ctrl + v vendor cake_show_vendor_list
ctrl + shift + c, ctrl + o component cake_show_component_list
ctrl + shift + c, ctrl + b behavior cake_show_behavior_list
ctrl + shift + c, ctrl + h helper cake_show_helper_list
ctrl + shift + c, ctrl + l lib cake_show_lib_list
ctrl + shift + c, ctrl + shift + l layout cake_show_layout_list
ctrl + shift + c, ctrl + shift + v view cake_show_view_list
ctrl + shift + c, ctrl + s css cake_show_css_list
ctrl + shift + c, ctrl + j javascript cake_show_javascript_list
ctrl + shift + c, ctrl + e element cake_show_element_list
ctrl + shift + c, ctrl + g config cake_show_config_list
ctrl + shift + c, ctrl + p plugin cake_show_plugin_list
ctrl + shift + c, ctrl + t test cake_show_test_list
ctrl + shift + c, ctrl + f fixture cake_show_fixture_list

Example

controller directory

controller

Open folder

  • You can open folder that contains the file.
Command Folder Function
ctrl + shift + c, s, f current directory cake_open_folder

Grep

  • This uses the find panel of Sublime Text.
  • exclude tmp directory and several extension file
Command Function
ctrl + shift + c, s, g cake_grep

Example

grep

If you want to add or delete the string in "Where", you need to write on settings.

Write on /Sublime Text 2/Packages/User/Preferences.sublime-settings

    "sublime_cakephp_find":
    {
        "grep_exclude_list": ["*.sh", "*.md"],
        "grep_include_list": [""]
    }

Find file

A command to jump to file for the current word.

Command Function
ctrl + shift + c, f cake_find

Example

<?php
    //app/Controller/SamplesController.php
    
    public $components = array("Auth");
                             //|----| : command on Auth -> AuthComponent
                             
    public $helpers = array("Post"); // app/View/Helper/PostHelper.php
                          //|----| : command on Post -> PostHelper

    public function index() {
        
        // : command with the following line -> AuthComponent::allow()
        $this->Auth->allow('index');
        
        // : command with the following line -> AuthComponent::$loginRedirect
        $this->Auth->loginRedirect = null;
    }
?>
Word File
Config/routes.php  
array('controller' => 'books', 'action' => 'post') app/Controller/BooksController.php : post()
Controller  
public $layout = 'default'; or $this->layout = 'default'; app/View/Layouts/default.ctp
$this->render('index'); app/View/Samples/index.ctp
$this->redirect('/Samples/index'); function index()
View  
$this->element("photo"); app/View/Elements/photo.ctp
$this->Html->script("popup"); app/webroot/js/popup.js
$this->Html->css("font"); app/webroot/css/font.css
$this->Html->image("cake.power.gif"); open "app/webroot/img/cake.power.gif"
$this->assign("side"), start("side"), prepend("side"), append("side") app/View/****.ctp : $this->fetch("side")
$this->fetch("side") app/View/****.ctp : $this->assign("side"), start("side"), prepend("side"), append("side")
<span class="notice"></span> find app/webroot/css/* and open file
<div id="footer"></div> find app/webroot/css/* and open file
Css  
background: #003d4c url('../img/cake.icon.png'); open "app/webroot/img/cake.icon.png"
Anywhere  
App::import('Lib', 'Libr'); app/Lib/Libr.php
App::uses('TimedBehavior', 'DebugKit.Model/Behavior'); app/Plugin/DebugKit/Model/Behavior/TimedBehavior.php
use Cake\Utility\CakeTime; // namespace lib/Cake/Utility/CakeTime.php
require or include APP . 'Config' . DS . 'routes.php'; app/Config/routes.php
$this->privateFunc(); function privateFunc()
$this->log("message"); lib/Cake/Core/Object.php : log()
self::CONST_K const CONST_K = 'K';
static::$static_k public static $static_k = 'k';
$this->Auth->allow('*'); lib/Cake/Controller/Component/AuthComponent.php : allow()
CakeTime::timezone(); lib/Cake/Utility/CakeTime.php : listTimezones()
CakeTime::$wordFormat lib/Cake/Utility/CakeTime.php : $wordFormat
"Auth" lib/Cake/Controller/Component/AuthComponent.php
$time = new CakeTime(); // It continues below. lib/Cake/Utility/CakeTime.php
$time->listTimezones(); lib/Cake/Utility/CakeTime.php : listTimezones()
$Email->template('default'); app/View/Emails/text/default.ctp
'datasource' => 'Database/Mysql' lib/Cake/Model/Datasource/Database/Mysql.php
Configure::load('setting'); app/Config/setting.php
Configure::read('db.default'); app/Config/*****.php (*1)
$fixtures = array('app.comment'); app/Test/Fixture/CommentFixture.php
__("Hello!"); app/Locale/eng/LC_MESSAGES/default.po
  • *1
    At first, the system searches "Configure::load("sample")" in "app/Config/core.php", "app/Config/bootstrap.php", and current file. if "app/Config/sample.php" is found, "db.default" word is looked for in file.

Run Test

If you want to run test, we recommend you this plug-in.

License

BSD License

Version

0.8.x

Reference

Reference code, Thank you.