Is there any good "go-to-definition" method for Atom? I tried go-to-definiton package, but it needs 2-10sec to to go to the definition. (In Sublime text it's a lot more quicker.
There is a topic on the atom discuss site about this subject. Since the last 22 days (4/08/2016) there is no native feature to go-to-definition.
Topic link: Is there a simple go-to-definition
But there is another package that you can try to use.
There's goto package which replaces symbols-view (which can be disabled); no ctags needed
Related
In Sublime Text 2, I am trying to type the code and have auto format command to rearrange and auto indent source code. If it is not possible to have a automatic formatter, would be nice to have a shortcut command to do it.
I am searching for something else besides the built-in "Reindent" option and the hard-to-make-work "PHP Beautifier" plugin.
I would like to know if someone found any nice auto formatter for PHP: any formatter that won't mess our PHP code. JSFormat seems to be not useful.
Is there any easy to "install and use" plugin?
PHPTidy is definitely good choice for PHP code formatting in SublimeText2.
You need to install package control package to enable you to install packaged in sublime text: link.
ctrl+shift+p -> type -> Package Control: Install Package
search for phpTidy -> hit enter
that is it - now you can format your code in WordPress coding convention.
How to format you code:
ctrl+shift+p -> type -> tidy -> Hit Enter
ctrl+alt+t
Hope this help.
There is a PHP code formatter named PhpBeautifier. Here you can find a Sublime Text plugin for this program and you can also install it via package control.
I have this set up as a keybind:
[
{
"keys": ["alt+shift+f"], "command": "reindent",
"args": {"single_line": false}
}
]
If you're looking for a bit more than that there is Tidy PHP under package management.
Update: Been some time, I'm now using PHP Coding Standards along with PHP CS Fixer which automates a lot of the cleanup done by autoformatting. This takes a fair bit of work / understanding of php cs to setup but its not too hard, and well worth it. Link
I've been searching this before also, but with no avail. Sublime text 2 probably doesn't support formatting PHP code natively. I have looked into ST2 packages - http://wbond.net/sublime_packages/community, but there is also nothing. Probably you'll have to do this in another editor.
Of course it would be nice, if someone would write a package for this, 'cause packages for formatting JS, JSON, HTML.. already exist.
This is an old subject, but as I found it via Google, here's an answer :
You can use the phpfmt plugin for Sublime Text 3, and configure it to respect code conventions (Such as PSR-0, PSR-1 or PSR-2).
The files will be beautified on save.
I'm using sublimetext-codeformatter
It supports PHP, JavaScript/JSON, HTML, CSS, SCSS, Python, Visual Basic/VBScript and maybe more in the feature. For PHP formatting it uses a fork of the phpfmt which works well. All languages-specific formatting can be set in one config file.
Not sure if this is what you are looking for, but are you aware that when you save your file as .php, Sublime Text 2 automatically highlights and indents according to its built in PHP rules. You can also select this from going to View, and then Syntax, and selecting PHP. But again, this is automatically done when you save the file as .php.
What do you use for automatic PHP docs generation.
I know about phpdocumentor. but it looks like it didn't have a single release within 2010.
Should I just use it or are there any alternatives?
You can try using DocBlox, a Documentation Generation application inspired on phpDocumentor.
Please see http://www.docblox-project.org for the website and/or http://demo.docblox-project.org/default for a demo.
We use Doxygen at work, but I must confess that I haven't used them much since setting it up in our continuous integration server. NetBeans and other IDEs parse and display the docs when you hover over and auto-complete items.
PHPdocumentor 2 is currently in alpha phase but still usable, so it seams that the project development ist continued.
does netbeans include phpdocumentator so you can comment your code?
is there some guide on how to use it, eg. how should i comment, how to read them and how to print them out?
It doesn't, but this link contains step-by-step instructions for setting it up.
https://blogs.oracle.com/netbeansphp/entry/generating_php_documentation_from_netbeans
I think the actual PHPDocumentor tool can be installed from PEAR. I doubt it would be included with Netbeans. I imagine Netbeans provides a way to make use of that facility once installed.
The IDE's ability to interpret your docblocks is built in to NetBeans and Eclipse, and probably other IDEs. That's not phpDocumentor working for you (but close I suppose).
Having phpDocumentor installed would mean having the ability to generate API docs from your code and its docblocks.
I'm going to be doing some PHP editing for my job this summer, and am looking for an effective Emacs setup for editing it. I'm already heavily invested in Emacs, so switching to another editor is not worthwhile.
Right now, I have nXhtml-mode, which provides a PHP mode with syntax highlighting (there are at least three different ones in the wild) as well as MuMaMo for editing PHP embedded in HTML. I just started using Auto-Complete and Anything for programming and general Emacs stuff, respectively.
What I'm really looking for is an effective way to get Emacs to really understand the project, beyond just highlighting. Etags looks like a good option, but it looks like the process for generating new tags is kind of arduous and manual (or at least not invisible). The nice thing about Etags is that they integrate well with Anything and Auto-Complete. Other potential options are gtags (though I'm hesitant to install non-elisp files, just for the complexity), vtags, or Semantic, which I've messed with before and seems complicated to set up, plus it doesn't look like it has support for PHP.
Another option is Imenu, but it only works for the current buffer, and I would like to be able to jump to function definitions in other files (preferably using Anything for completion of the name).
The projects I will be working on are not that big (about 30,000 lines total), so the overhead of Etags probably won't be that big of an issue, but I'd rather not use it if there is a better solution.
So what is your preferred PHP editing system?
In addition to features you are already familiar with, I suggest you the followings.
ETags
I do not use ETags, but there is a question already on SO How to programmatically create/update a TAGS file with emacs. No good answer was posted, though, but it may be a good entry point to get an idea.
Debugging
Flymake is a mode to get on the fly syntax checking. It has support for PHP as well. It hints at syntax errors immediately as you type. The Flymake version shipped with Emacs 23 contains PHP support. If you have previous version, check Sacha Chua's post on Emacs and PHP: On-the-fly syntax checking with Flymake.
Another useful package is Geben that allows you to debug your scripts interactively. For PHP, you can use XDebug. There is a detailed tutorial on how to do that, see Debug php in emacs with geben.
Documentation lookup
PHP Mode has a nice feature to lookup the function's definition in PHP's manual in your web browser (M-x php-search-documentation or C-c C-f). You can combine it with Emacs-W3M to get the relevant manual page without leaving Emacs.
web-model.el (available on web-mode.org) handles pretty well php blocks embedded in an html document. This major mode will also highlight js and css parts.
As an alternative to ETags, consider GNU Global, aka "GTags". Global is a lot smarter about finding tags tables, and is fairly fast to update. Emacs-fu has a nice post about doing this on-the-fly.
BTW, if you're using the Windows port of GNU Global with a Windows Emacs build, use the DJGPP ("DOS") version. The MinGW ("Win32") build seems to have a problem with path names.
In addition to the answer given on May 28 '09, I think I can add some packages to it which enhanced my PHP experience on Emacs.
Auto-completion
ac-php is in my opinion a good additions to Etags. All references to a tag will be found with etags, but the definition with ac-php. ac-php is also configurable to which directories should be included. For example, while developing a wordpress plugin, you can add a reference to the directory containing the wordpress files in .ac-php-conf.json (which resides in the project root) and it will auto-complete, jump to reference, etc. This package supports company-mode and auto-complete.
Here's an example configuration of ac-php:
(use-package ac-php
:ensure t
:bind (:map
php-mode-map
("M-+" . ac-php-find-symbol-at-point)
("M-]" . ac-php-location-stack-back)
("<menu> r" . ac-php-remake-tags)
("<menu> R" . ac-php-remake-tags-all)))
Another option would be to use phpactor, but the Emacs interface is at the time of writing still in alpha stage, with which I also hardly have any experience - except for the constructor completion, which works pretty well.
Error checking
In addition to syntax errors, Flycheck supports phpMessDetector and phpCodeSniffer out of the box. This enables you to have more enhanced notice/warning/error reporting based on supported coding standard and best practices.
Another package I like for static analysis is PHPStan Emacs interface, which reports potential errors in your code (including incorrect type hints).
Additional formatting
I also use phpcbf (which apparantly is archived). This package formats the buffer into the wanted coding standard.
Semantic
For anyone in the dark, Semantic is a built-in Emacs package and provides IDE like features. Here's an example how to include semantic for php-mode:
(add-hook 'php-mode-hook (lambda ()
(require 'semantic/symref/grep)
(add-to-list 'semantic-symref-filepattern-alist '(php-mode "*.php" "*.inc"))
(semantic-mode)))
Imenu
For including imenu jumping to definitions, another example configuration:
This is the sidebar for jumping to in-file methods and functions.
(use-package imenu-list
:ensure t
:config
(setq imenu-list-focus-after-activation t)
:bind (:map php-map
("<menu> \\" . imenu-list-smart-toggle)))
Example config for helm support in jumping to definitions in all project files:
(use-package imenu-anywhere
:ensure t
:after helm
:bind (:map php-map
("<menu> |" . helm-imenu-anywhere)))
Additional debugging
Besides geben, I like to use psysh, which by dropping in eval(\Psy\sh()); gives a repl on that line of code and gives access to all definitions and whatever else one would have access to (ofcourse, after requiring it in composer).
More generally handy packages
Snippets
Maybe a bit obvious for everyone already experienced with Emacs, but yasnippet is also very handy for writing your own templates. There are also packages that include a lot of predefined templates for all sorts of languages, but I write my own to keep Emacs a little less bloated than my set-up already is, it also helps me remember them more easily.
Project management
Excuse the obviousness again, but Projectile is also a very good package which by default includes git support for scoping the project.
Offline documentation
If you use Zeal for offline documentation browsing, there's also zeal-at-point. Example configuration, if you use, lets say: PHP, CodeIgniter and WordPress:
(use-package zeal-at-point
:ensure t
:bind (("<menu> z" . zeal-at-point))
:config
(add-to-list 'zeal-at-point-mode-alist '(php-mode . ("codeigniter" "wordpress" "php"))))
I'm using version 3.3.2, I know that regular Eclipse for Java does variable highlighting.
Notepad++ does it regardless of what language you're using (if you select any text, it highlights similar text)
I know it's not critically important, and a back/forward incremental search is an adequate workaround, but it would be nice to have.
Update Looks like I had PDT 1.03, (current version is 2.0), I have Eclipse 3.2.2. Needed to look in "Help -> Software Updates -> Manage Configuration", not just "Help -> About".
You can download new PDT 2.0 All-in-one together with Eclipse 3.4 - this feature as "mark occurences" is here an there is some new features. I use it now and found it stable.
http://www.eclipse.org/pdt/downloads/
I believe 'mark occurrences' is the option which is the closest of what you call 'syntax highlighting'
But PHP Development Tools (PDT) had not that feature in 2007, according to this discussion.
However this bug says PDT1.1 has now the ability to mark occurrences.
Full description in this pdf document.
I think your question in poorly worded. Syntax highlighting, and highlighting all similar strings are very different.
Not sure about PDT but I would suggest to try PHPEclipse plugin instead, which is much more powerful. It gives you pretty much everything that Eclipse provides for java - marking occurrences, Ctrl-click navigation, code completion, etc.
Another trick is to highlight the word then right click -> refactor -> rename OR just Alt-Shift-R
This highlights all occurrences of the variable.
Esc key to stop highlighting.
Just be sure you don't accidentally rename it (easy enough to undo if you do).