PHP Companion
A Sublime Text plugin that provides cool stuff for PHP 5.3+ coding session.
Details
Installs
- Total 238K
- Win 139K
- Mac 49K
- Linux 49K
Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 4 | 2 | 4 | 9 | 6 | 11 | 9 | 0 | 0 | 8 | 9 | 5 | 5 | 12 | 20 | 12 | 10 | 12 | 6 | 8 | 5 | 8 | 11 | 8 | 6 | 4 | 7 | 10 | 10 | 3 | 8 | 13 | 2 | 5 | 10 | 14 | 10 | 9 | 17 | 10 | 10 | 10 | 12 | 11 | 9 | 13 |
Mac | 1 | 0 | 1 | 1 | 1 | 6 | 3 | 0 | 0 | 0 | 7 | 1 | 1 | 1 | 5 | 1 | 4 | 2 | 2 | 0 | 3 | 2 | 3 | 1 | 2 | 1 | 1 | 3 | 2 | 1 | 2 | 2 | 0 | 1 | 2 | 5 | 4 | 3 | 3 | 4 | 4 | 3 | 5 | 1 | 3 | 2 |
Linux | 1 | 1 | 2 | 1 | 3 | 3 | 2 | 0 | 0 | 6 | 3 | 1 | 1 | 1 | 5 | 2 | 0 | 3 | 1 | 1 | 4 | 8 | 3 | 2 | 2 | 2 | 4 | 5 | 1 | 5 | 4 | 1 | 0 | 4 | 6 | 0 | 2 | 3 | 5 | 2 | 2 | 4 | 1 | 3 | 5 | 3 |
Readme
- Source
- raw.githubusercontent.com
Sublime PHP Companion
This Sublime Text 3 Package provides cool stuff for PHP 5.3+ coding session.
Installation
Package control
Just search for PHP Companion in package control and you're ready.
Keybinding
The package no longer provides keybindings. You will have to install your own shortcuts. The Default.sublime-keymap-sample will give you the shortcuts I personally use.
Commands
find_use
Just place your cursor on a class name, hit the F5 key (personal shortcut) and that's it.
It will show you the different namespace that match your class, pick up one and you're done.
PHP Companion will sort your uses statement in alphabetical order. This can be
configured to sort by line length with the use_sort_length
user setting.
expand_fqcn
This command expands the class under the cursor to its FQCN (Fully Qualified Class Name).
You have two keys for this command F6 and shift+F6 (personal shortcut) that respectively expand
with and without the leading namespace separator \
.
import_namespace
Just hit the F4 key (personal shortcut), it will add the namespace definition based on the absolute filename of the current file. I use a simple trick to determine where the namespace begun, actually the namespace will start at the first CamelCased folder.
If a namespace is already declared, the command will shout how crazy you are in the status bar.
Warning: This feature requires a filename so the command won't work in an unsaved buffer.
goto_definition_scope
Hit shift+F12 (personal shortcut) to search for a method definition based on the current scope. It will fallback to the “goto_definition” command if a match was not found.
insert_php_constructor_property
Hit F7 (personal shortcut) to insert both a constructor argument and its according property. The property will be private
by default but you can change it with the visibility
setting.
implement
Place your cursor on a class, abstract class or an interface name and hit the F3 key (personal shortcut). Matching interfaces or classes will be shown. Select one and then import all or one of the methods from that interface or class.
See use_todo_implement
setting.
Settings
Settings can be stored either in your system wide “PHP Companion.sublime-settings” file or in the project settings file. This allows you to set preferences per-project if you need to.
If you're storing settings in a project file, put them in a phpcompanion node like this:
"phpcompanion": {
"exclude_dir": [
"vendor",
"build"
]
}
IMPORTANT : Sublime Text 4 does not index files and folders ignored by .gitignore. Update your sublime settings with :
"index_exclude_gitignore": false
exclude_dir
List of directories to exclude when searching for the class declaration file. Path is relative to the project directory.
Please note that the filtering is done after the search in the index. So this option has no impact on performance, it's just a convenient way to avoid duplicate namespace declaration in some case.
use_sort_length
When importing use statements with the find_use command, sort statements by the length of the line.
use_todo_implement
When an interface or abstract class is implemented, this option is used to customize the method body of the newly added methods.
The available options are true and false.
"use_todo_implement": true
:
“
public function methodName()
{
// TODO: Implement 'methodName' method.
}
`"use_todo_implement": false`:
public function methodName() { throw new \Exception("Method 'methodname' not implemented”); }
## Successor of SublimeCTagsPHP
This plugin is the successor of [SublimeCTagsPHP](https://github.com/erichard/SublimeCTagsPHP). PHP Companion uses the built-in index of Sublime Text 3 instead of CTags.
**Warning!** PHP Companion does not work on Sublime Text 2 and never will.
## Licence
All of Sublime PHP Companion is licensed under the MIT license.
Copyright (c) 2013-2020 Erwan Richard
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.