Facilitation in projects with PHP

14

I work with PHP using Sublime Text and would like something similar to what it's like in Eclipse. For example:

In Eclipse I can open exactly where the method was declared. In Sublime Text I did not find any similar option, I use the shortcut CTRL + mouse click to open method declarations and everything.

Does Sublime Text have any options that make it easier to navigate my project to check the method / function declarations?

    
asked by anonymous 28.03.2017 / 19:58

3 answers

12
  

Most content here "maybe" only applies to Sublime Text 3, please note that Sublime Text 2 was last updated at July 8, 2013

For PHP as well as other languages the plugin that works a lot is CodeIntel, it uses autocomplete as it types, so it does not need any commands. It recognizes functions, classes, and custom namespaces (created in your project), even if it is in a different file.

  • Install SublimeCodeIntel Preferences > Package Control > Install Package

  • Type SublimeCodeIntel , and select it to install

  • Install PhpIntel Preferences > Package Control > Install Package

  • Type PhpIntel , and select it to install

  • You should now select the folder of your project and drag it to SublimeText, like this:

    Nowbythesublimeitself,navigatetotheprojectfiles,openanyfileandpressCtrl+S,CodeIntelwilltakesometimethefirsttime,folderofyourprojectanotherfoldercalled.phpintel,itcontainsamappingandcachesofyourclasses,everytimeyouuseCtrl+Sitwillupdatethis,justtestitout:

    Seethatthenamespaceandclassarenotnative,eventhoughitrecognizesnativePHPaswell.

    Othertips

    OtherinterestingsettingsyoucantakeintoaccountareeditingtheSettings,gotoPreferences>Settings,itwillopenawindowwithtwodocuments,editonlytheoneontheright,therearesomesettingsyoucanuse:

    Removeunnecessaryspaceswhensaving:

    "trailing_spaces_trim_on_save": true, 
    

    Change TABs by spaces:

    "translate_tabs_to_spaces": true,
    

    Use TABs as 4 spaces, you can adjust here:

    "tab_size": 4,
    

    Show the encoding of the current file in the SublimeText footer, it helps to avoid many headaches:

    "show_encoding": true,
    

    Line breaks use only LF :

    "default_line_ending": "unix",
    

    Show which type of "newline" uses, for example: Unix (if the rows in the document end in LF ) or Windows (if the rows in the document end in CR LF ): p>

    "show_line_endings": true,
    

    Add line break at the end of the document if necessary (of course this is optional):

    "ensure_newline_at_eof_on_save": true,
    

    It should look like this:

    {
        "always_show_minimap_viewport": true,
        "bold_folder_labels": true,
        "font_size": 11,
        "highlight_line": true,
        "ignored_packages":
        [
            "Vintage"
        ],
        "indent_guide_options":
        [
            "draw_normal",
            "draw_active"
        ],
        "line_padding_bottom": 3,
        "line_padding_top": 3,
        "overlay_scroll_bars": "enabled",
        "show_encoding": true,
        "tab_size": 4,
        "trailing_spaces_trim_on_save": true,
        "translate_tabs_to_spaces": true,
        "show_encoding": true,
        "show_line_endings": true,
        "ensure_newline_at_eof_on_save": true,
        "word_wrap": true
    }
    

    Extra

    Spell checker, has no relation, but a spell checker can help avoid embarrassment sometimes, in case you can manually install it, which can be quite complex, I even tried to download .dic from LibreOffice and gave it problem with Unicode , so I ended up copying .dic from the Firefox folder, but this is a bit tricky, so I'll point you to the same repository, select the preferred language in link and download .dic and .aff, for example:

    Open the package folder, if it is Linux or Mac:

    • ~/.config/sublime-text-3/Packages

    If Windows is maybe the folder so SublimeText\Data\Packages\

    Create a folder called Portuguese for example and copy both files to it, you may have to close the sublime and open it again, then go to View > Dictionary and see if Portuguese appears, or you can point to Settings too, like this:

    "dictionary": "Packages/Portuguese/Portuguese (Brazilian).dic",
    

    And enable the spell-checker permanently:

    "spell_check": true,
    

    It should look like this:

    {
        "always_show_minimap_viewport": true,
        "bold_folder_labels": true,
        "dictionary": "Packages/Portuguese/Portuguese (Brazilian).dic",
        "font_size": 11,
        "highlight_line": true,
        "ignored_packages":
        [
            "Vintage"
        ],
        "indent_guide_options":
        [
            "draw_normal",
            "draw_active"
        ],
        "line_padding_bottom": 3,
        "line_padding_top": 3,
        "overlay_scroll_bars": "enabled",
        "show_encoding": true,
        "spell_check": true,
        "tab_size": 4,
        "trailing_spaces_trim_on_save": true,
        "translate_tabs_to_spaces": true,
        "show_encoding": true,
        "show_line_endings": true,
        "ensure_newline_at_eof_on_save": true,
        "word_wrap": true
    }
    
        
    28.03.2017 / 20:44
    2

    I work with Sublime Text as well. In the version I use, the 3 (its probably the same), just hover over a function and wait for 1 to 2 seconds that a small popup with a list of files containing the function appears on the cursor. If Sublime does not find any files with this function it does not appear. I did not go after setting it up, but maybe I have something for that. But as far as I know, it only works with functions.

        
    28.03.2017 / 20:44
    2

    There is the PHPIntel package that brings go to declaration functions by placing the pointer over the method / class and pressing ctrl + f5

    link

        
    28.03.2017 / 20:46