-
Notifications
You must be signed in to change notification settings - Fork 4
/
README
183 lines (146 loc) · 7.73 KB
/
README
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
php+-mode README
**Note**: This package is no longer actively maintained. While it still has
some neat features, php-mode has had better support and updates for newer
versions of PHP. We have discussed getting php+-mode features into php-mode,
but nothing has come of this as of yet. Feel free to continue using php+-mode,
and if you find and fix any issues, don't hesitate to send pull requests.
Thanks, and I hope that php+-mode has been helpful.
===============================================================================
REQUIREMENTS
php+-mode comes with pretty much everything neccesary to run it. Emacs version
23 or later is recommended.
Note that there is a known issue with company-mode version 0.5, or at least
with the version available from elpa. See the INSTALL section for details.
For php-test, your system needs to have PHP installed on it for linting, and to
use any of the testing programs (phpunit, phpcs, phpmd), you need to have those
installed as well.
If you would like electric functionality (for instance, when you type ( the
matching ) is added for you, etc), you can use php-electric-mode, which at the
time of this writing can be found at http://stcamp.net/share/php-electric.el
===============================================================================
INSTALL
Ensure that all required modes and elisp files are on the load path and loaded.
Also ensure that php+-mode's elisp files are on the load path and loaded. The
easiest way to obtain php+-mode is through package.el, which is included in
Emacs 24, but can be obtained for Emacs 23. Add the melpa repoitory to your
package repositores list (instructions can be found at
http://melpa.milkbox.net/#installing). Otherwise, you can get php+-mode
straight from github at https://github.com/echosa/phpplus-mode. This is
recommended for anyone who wants to help develop php+-mode or contribute
changes/fixes.
Once you have donwloaded and installed php+-mode, put this in your .emacs file:
(require 'php+-mode)
(php+-mode-setup)
Either execute these two lines of code, or restart emacs.
At this point, you should be ready to use php+-mode. Just open up a php or
phtml file, and you should find yourself in php+-mode. You should have a PHP+
menu and "php+" should be in the mode line.
To get an idea of what you can do with php+-mode, you can get a description and
list of keybindings/functions for php+-mode by typing:
C-h m
when inside of a php+-mode file.
If you have existing projects, or would like to add a new one, you can add them
to the php-project list by running:
M-x php-project-add
If you are starting a new project, you can use create the directories and add
the new project to your php-project-list all at once by running:
M-x zf-create-directory-structure
Notes:
There is a known issue with company-mode version 0.5. If company mode isn't
loading, or you get errors about pysmell or gtags, you need to remove the
gtags and pysmell backends from company-mode. Cutomize the variable
`company-backends` and remove the lines for `company-pysmell` and
`company-gtags`.
While you're at it, you can also add a User-Defined company backend to the
merged backends section of company-backends called `company-my-php-backend`.
This backend will check the php.net documentation for completions of php
keywords and such.
===============================================================================
CONFIGURATION
You can use the various "customize ..." options in the php+-mode menus to
customize php+-mode. Hopefully most of these customize options are
self-explanatory. For a full list of cutomize options, just browse through
each of the customize groups with `M-x customize-group`:
- php-completion
- php-doc
- php-format
- php-parse
- php-project
- php-tags
- php-test
- php+-mode
***********
EXECUTABLES
You may need to tell emacs where various executables are. For instance, if
php, phpunit, or phpcs (if you use the latter two) are not on your operating
system's execute path, you may need to customize the following variables to
tell them explicitly where the executables are:
php-exectuable
phpcs-shell-command
phpmd-shell-command
phpunit-shell-command
************************
PROJECTS AND DIRECTORIES
To add a project to the projects list the easy way, run:
M-x php-project-add
Alternatively, you can add projects manually by going to
PHP+ -> Project -> Customize Projects
in the menu or by typing
M-x customize-variable php-project-list
If you use customize, the main variable to setup here is the PHP Project List.
This is a list of directories on your computer that correspons with a set of
php files or project.
To setup a project, insert a new item in the list and fill in the fields:
Project Nickname - This is just a nickname for the project.
Project Directory - This is the base directory for the project. For projects
using the Zend Framework, this will typically be the directory where
application, library, etc, are.
Project TAGS File - This is the TAGS file for the project.
Extra TAGS Directories - A list of directories to include when generating the
project TAGS file. You may want to put the Zend Framework directories here.
Project directory is included by default.
PHPUnit Config File - This is the xml configuration file that phpunit will use
when phpunit is run from php+-mode.
phpcs/phpmd Subdirectories - This is a list of directories which should be
included when phpcs is run for the project directory.
phpdoc overrides - these are project specific phpdoc information to include in
doc blocks. Project agnostic defaults can be set by customizing php-doc.
Zend Framework Global Namespace - This is the namespace of files generated
outside of modules (in the "main area" so to speak). Traditionally, this
was "Default" but has recently more likely to be "Application". This will
result in, for instance, models outside of modules being named
Default_Model_<name> or Application_Model_<name>. (Only necessary for
projects using Zend Framework).
Zend Framework Default Module - This is the default module that will be used as
default if the Zend project makes use of a default module in the modules
directory instead of keeping default controllers, models, etc, inside the
applications directory (not in modules). (Only necessary for projects
using Zend Framework).
****
TAGS
Tags files are basically compiled files of symbols that link various files
together, allowing you, for instance, to find the definition of a function by
"following" its name in a call somewhere else in your code. This is done in
emacs using the find-tag function, bound to M-. by default.
In order to use tags, you have to do two things:
1.) Create a tags file
2.) Load the tags file
The php-tags portion of php+-mode eases this process. It requires you to have
exhuberant-ctags installed. This is different from ctags. Basically, in my
experience, if your ctags does not have a -e flag, you need to get
exhuberant-ctags to use. There is a customizable variable
php-tag-shell-command where you can set the path to your ctags command if
neccessary.
To create a tags file you can either go to
PHP+ -> Tags -> Create tags file
in the menu, or run
M-x php-create-tag-file
A tags file will be created in the location given in the php-project-list
settings for the current project. After the tags file is generated, you will
be prompted to load the newly created tags file.
Once the tags files is created, php-project will automatically load it whenever
you switch to a file or buffer that resides inside that project's directory.
===============================================================================
AUTHORS
php+-mode is written and maintained by Brian Zwahr <echosa@gmail.com> and
Mike Dwyer <mdwyer@ehtech.in>.