-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathINTEGRATION
83 lines (47 loc) · 2.17 KB
/
INTEGRATION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
====== Integration of phptidy into editors ======
Instead of running phptidy from command line, you can also integrate it into
your editor or IDE.
There are some possible approaches:
1) run phptidy on the whole project
cd <project_path> && phptidy.php replace
2) run phptidy only on a single file
Limitation: Since no other project files are read, no new see-tags will be
added to docblocks.
2a) run phptidy on the file
cd <project_path> && phptidy.php replace <file>
2b) let phptidy read from STDIN and write to STDOUT
| phptidy.php --quiet - |
Limitations:
- Since there is no file name, new file docblocks won't get a file name.
- If you want to use a config file, you either have to change to the project
path first:
| ( cd <project_path> && phptidy.php --quiet - ) |
or specify the absolute path to the config file:
| phptidy.php --quiet --config=/path/to/.phptidy-config.php - |
Some examples:
=== PhpStorm IDE ===
You can run phptidy on the whole project as an "external tool":
Settings/Preferences -> Tools -> External Tools -> +
Program: phptidy.php
Parameters: replace
Working directory: $ProjectFileDir$
In case phptidy.php can't be found in your PATH, you have to specify the
absolute path in the Program field. There also seems to be a known problem:
http://ify.io/getting-webstorm-external-tools-to-work-on-webstorm-on-osx/
=== VIM ===
You can run phptidy on the current buffer.
Install the vim autoformat addon:
https://github.com/Chiel92/vim-autoformat
Add the following lines to your ~/.vimrc file:
let g:formatprg_php = "phptidy.php"
let g:formatprg_args_php = "--quiet -"
If you want to use a config file, you can either change to the project path:
let g:formatprg_php = "cd <project_path> && phptidy.php"
or specify the absolute path to the config file:
let g:formatprg_php = "--quiet --config=/path/to/.phptidy-config.php -"
Unfortunately in both cases you will have to edit your ~/.vimrc to switch
between projects with different config files.
You should now be able to format an open PHP file using the following command:
:Autoformat
Additional examples are welcome!
Magnus Rosenbaum <[email protected]>