<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>sacha chua :: enterprise 2.0 consultant, storyteller, geek &#187; php</title>
	<atom:link href="http://sachachua.com/wp/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://sachachua.com/wp</link>
	<description>I help people connect through blogs, wikis, other Web 2.0 tools. I'm also writing a book about Emacs.</description>
	<pubDate>Fri, 21 Nov 2008 21:28:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Emacs and PHP tutorial: php-mode</title>
		<link>http://sachachua.com/wp/2008/07/30/emacs-and-php-tutorial-php-mode/</link>
		<comments>http://sachachua.com/wp/2008/07/30/emacs-and-php-tutorial-php-mode/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 13:16:43 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[wickedcoolemacs]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/?p=5014</guid>
		<description><![CDATA[php-mode is responsible for syntax highlighting, indentation, and other major PHP-specific modifications to your editing environment. There are a number of PHP modes available for Emacs. In this project, you&#039;ll learn how to set up the php-mode available from http://sourceforge.net/projects/php-mode/ . At the time of this writing, the current version is 1.4.0 and the maintainer [...]]]></description>
			<content:encoded><![CDATA[<p>php-mode is responsible for syntax highlighting, indentation, and other major PHP-specific modifications to your editing environment. There are a number of PHP modes available for Emacs. In this project, you&#039;ll learn how to set up the php-mode available from <a href="http://sourceforge.net/projects/php-mode/">http://sourceforge.net/projects/php-mode/</a> . At the time of this writing, the current version is 1.4.0 and the maintainer is Aaron Hawley.</p>
<p>
Download the latest php-mode.el from <a href="http://php-mode.sourceforge.net/">http://php-mode.sourceforge.net/</a> and save it to a directory in your load-path. I like to organize my Emacs Lisp files in a directory called ~/elisp. To add PHP support to your Emacs, add the following lines to your ~/.emacs:
</p>
<p><pre class="example" lang="lisp">
 (add-to-list 'load-path "~/elisp")
 (require 'php-mode)
</pre>
</p>
<p>
This configures Emacs to automatically recognize files ending in &#034;.php&#034;, &#034;.phps&#034;, &#034;.php3&#034;, &#034;.php4&#034;, &#034;.phtml&#034;, and &#034;.inc&#034; as PHP files. To associate more extensions with PHP files, add lines like this example to your ~/.emacs: </p>
<p><pre class="example" lang="lisp">
 (add-to-list 'auto-mode-alist '("\\.module$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.install$" . php-mode))
 (add-to-list 'auto-mode-alist '("\\.engine$" . php-mode))
</pre>
</p>
<p>
This associates php-mode with the extensions used by Drupal, a PHP framework. When you open a file with the specified extension, it should be highlighted according to PHP syntax.
</p>
<p>
Here are some useful commands:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<col align="left"></col><col align="left"></col><col align="left"></col></p>
<tbody>
<tr>
<td>TAB</td>
<td>c-indent-command</td>
<td>Indent the current line</td>
</tr>
<tr>
<td>M-;</td>
<td>comment-dwim</td>
<td>Add a line comment, comments or uncomments the currently-selected region, or does other smart comment-related actions</td>
</tr>
<tr>
<td>C-c C-f</td>
<td>php-search-documentation</td>
<td>Search the online PHP manual for the current word</td>
</tr>
<tr>
<td>C-c RET</td>
<td>php-browse-manual</td>
<td>View the online PHP manual</td>
</tr>
<tr>
<td>C-c .</td>
<td>c-set-style</td>
<td>Change coding style</td>
</tr>
<tr>
<td>C-M-a, C-M-e</td>
<td>c-beginning-of-defun, c-end-of-defun</td>
<td>Go to the beginning or end of the current function</td>
</tr>
<tr>
<td>C-M-h</td>
<td>c-mark-function</td>
<td>Select the current function</td>
</tr>
<tr>
<td>M-a, M-e</td>
<td>c-beginning-of-statement, c-end-of-statement</td>
<td>Go to the beginning or end of the current statement</td>
</tr>
</tbody>
</table>
<p>
Here are some variables you may wish to customize:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<col align="left"></col><col align="left"></col></p>
<tbody>
<tr>
<td>indent-tabs-mode</td>
<td>Set this to nil if you want to insert spaces instead of tabs</td>
</tr>
<tr>
<td>case-fold-search</td>
<td>Set this to t if you want case-insensitive search.</td>
</tr>
<tr>
<td>c-basic-offset</td>
<td>Set your tab size or number of spaces used as a basis for indentation</td>
</tr>
</tbody>
</table>
<p>
You can either customize these variables globally with M-x customize or set them for php-mode. Here&#039;s an example that sets up a buffer with the coding style recommended for Drupal:
</p>
<p><pre class="example" lang="lisp">
 (defun wicked/php-mode-init ()
   "Set some buffer-local variables."
   (setq case-fold-search t)
   (setq indent-tabs-mode nil)
   (setq fill-column 78)
   (setq c-basic-offset 2)
   (c-set-offset 'arglist-cont 0)
   (c-set-offset 'arglist-intro '+)
   (c-set-offset 'case-label 2)
   (c-set-offset 'arglist-close 0))
 (add-hook 'php-mode-hook 'wicked/php-mode-init)
</pre>
</p>
<p>
You can further customize the indentation by moving the point to where the indentation needs improvement and typing C-c C-o (c-set-offset).
</p>
<p>
To try automatic indentation, press C-j (newline-and-indent). If you like that behavior, you can make it the default in php-mode by adding the following line in ~/.emacs:
</p>
<p>
(define-key php-mode-map (kbd &#034;RET&#034;) &#039;newline-and-indent)
</p>
<p>
You may also be interested in M-x show-paren-mode, which shows the matching parenthesis, bracket or brace for the character at point. You can enable it automatically by adding the following line to your ~/.emacs:
</p>
<p><pre class="example" lang="lisp">
   (setq show-paren-mode t)
</pre>
</p>
<p>
It&#039;s a good idea to separate PHP and HTML code. This is not only better coding practice, but it also makes developing in Emacs much easier. php-mode focuses on PHP-specific behavior and does not have special support for HTML. Emacs has a number of packages that allow you to work with multiple modes like php-mode and html-helper-mode in a single buffer, but they don&#039;t always work, and indentation can be confusing. If you must work with large segments of both PHP and HTML in the same file, check out MultipleModes (<a href="http://www.emacswiki.org/cgi-bin/wiki/MultipleModes">http://www.emacswiki.org/cgi-bin/wiki/MultipleModes</a>) for tips.</p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/07/30/emacs-and-php-tutorial-php-mode/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs and PHP: There&#039;s more than one way to do it, of course</title>
		<link>http://sachachua.com/wp/2008/07/30/emacs-and-php-theres-more-than-one-way-to-do-it-of-course/</link>
		<comments>http://sachachua.com/wp/2008/07/30/emacs-and-php-theres-more-than-one-way-to-do-it-of-course/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 12:25:04 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[emacs]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sachachua.com/wp/2008/07/30/emacs-and-php-theres-more-than-one-way-to-do-it-of-course/</guid>
		<description><![CDATA[The PhpMode page on EmacsWiki lists five options for developing PHP in Emacs. I&#039;m currently using the php-mode maintained by Aaron Hawley, and I&#039;m quite happy with it. I&#039;m curious about the php-mode maintained by Ahmet Usal, though, as it has extensive templating support and electric behavior. It seems to have abbreviations and argument lists [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.emacswiki.org/cgi-bin/wiki/PhpMode">PhpMode</a> page on EmacsWiki lists five options for developing PHP in Emacs. I&#039;m currently using the <a href="http://sourceforge.net/projects/php-mode/">php-mode maintained by Aaron Hawley</a>, and I&#039;m quite happy with it. I&#039;m curious about the <a href="http://mewde.googlecode.com/files/php-mode.el">php-mode maintained by Ahmet Usal</a>, though, as it has extensive templating support and electric behavior. It seems to have abbreviations and argument lists for every PHP function, and I might borrow the code and convert it to a yasnippet file if I don&#039;t end up using this. I&#039;ll switch to Ahmet Usal&#039;s php-mode today, see what it feels like, and post my notes. Has anyone else tried both? </p>

<!-- start wp-tags-to-technorati 0.95 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2008/07/30/emacs-and-php-theres-more-than-one-way-to-do-it-of-course/feed/</wfw:commentRss>
		</item>
		<item>
		<title>phpdev</title>
		<link>http://sachachua.com/wp/2005/01/16/phpdev/</link>
		<comments>http://sachachua.com/wp/2005/01/16/phpdev/#comments</comments>
		<pubDate>Sun, 16 Jan 2005 05:26:00 +0000</pubDate>
		<dc:creator>Sacha Chua</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sachachua.com/notebook/wiki/2005.01.16.php#anchor-1</guid>
		<description><![CDATA[<p>Check out <a href="http://www.firepages.com.au">http://www.firepages.com.au</a> for a local-only (by default)
Apache/<nop>MySQL/PHP install for Windows.</p>

<p>E-Mail from Ian Utting</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/php" rel="tag">php</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Check out <a href="http://www.firepages.com.au">http://www.firepages.com.au</a> for a local-only (by default)
Apache/<nop>MySQL/PHP install for Windows.</p>

<p>E-Mail from Ian Utting</p>

<p>On Technorati: <a href="http://www.technorati.com/tag/php" rel="tag">php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sachachua.com/wp/2005/01/16/phpdev/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
