Source of: /manual/en/internals2.structure.files.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/internals2.structure.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'internals2.structure.files.php',
1 => 'Files which make up an extension',
),
'up' =>
array (
0 => 'internals2.structure.php',
1 => 'Extension structure',
),
'prev' =>
array (
0 => 'internals2.structure.php',
1 => 'Extension structure',
),
'next' =>
array (
0 => 'internals2.structure.basics.php',
1 => 'Basic constructs',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="internals2.structure.files" class="sect1">
<h2 class="title">Files which make up an extension</h2>
<p class="para">
Whether created by hand, using <strong class="command">ext_skel</strong>, or by an
alternate extension generator, such as
<a href="http://codegenerators.php-baustelle.de/" class="link external">» CodeGen</a>,
all extensions will have at least four files:
</p>
<dl>
<dt class="varlistentry">
<span class="term"><var class="filename">config.m4</var></span>
</dt><dd class="listitem">
<p class="para">
UNIX build system configuration (see
<a href="internals2.buildsys.configunix.php" class="xref">Talking to the UNIX build system: config.m4</a>)
</p>
</dd>
<dt class="varlistentry">
<span class="term"><var class="filename">config.w32</var></span>
</dt><dd class="listitem">
<p class="para">
Windows buildsystem configuration (see
<a href="internals2.buildsys.configwin.php" class="xref">Talking to the Windows build system: config.w32</a>)
</p>
</dd>
<dt class="varlistentry">
<span class="term"><var class="filename">php_counter.h</var></span>
</dt><dd class="listitem">
<p class="para">
When building an extension as static module into the PHP binary the
build system expects a header file with <i>php_</i>
prepended to the extension name which includes a declaration for a
pointer to the extension's module structure. This file usually contains
additional macros, prototypes, and globals, just like any header.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><var class="filename">counter.c</var></span>
</dt><dd class="listitem">
<p class="para">
Main extension source file. By convention, the name of this file
is the extension name, but this is not a requirement. This file
contains the module structure declaration, INI entries, management
functions, userspace functions, and other requirements of an extension.
</p>
</dd>
</dl>
<p class="para">
The buildsystem files are discussed elsewhere; this section concentrates on
the rest. These four files make up the bare minimum for an extension, which
may also contain any number of headers, source files, unit tests, and other
support files. The list of files in the counter extension might look like
this:
</p>
<div class="example">
<p><b>Example #1 Files in the counter extension, in no particular order</b></p>
<div class="example-contents screen">
<div class="cdata"><pre>
ext/
counter/
.cvsignore
config.m4
config.w32
counter_util.h
counter_util.c
php_counter.h
counter.c
package.xml
CREDITS
tests/
critical_function_001.phpt
critical_function_002.phpt
optional_function_001.phpt
optional_function_002.phpt
</pre></div>
</div>
</div>
<div id="internals2.structure.files.misc-files" class="sect2">
<h3 class="title">Non-source files</h3>
<p class="para">
The <var class="filename">.cvsignore</var> file is used for extensions which are
checked into one of the PHP <strong class="command">CVS</strong> repositories (usually
<a href="http://pecl.php.net/" class="link external">» PECL</a>); the one generated by <strong class="command">ext_skel</strong> contains:
</p>
<div class="informalexample">
<div class="example-contents programlisting">
<div class="cvsignorecode"><pre class="cvsignorecode">.deps
*.lo
*.la</pre>
</div>
</div>
</div>
<p class="para">
These lines tell <strong class="command">CVS</strong> to ignore interim files generated
by the PHP buildsystem. This is only a convenience, and can be omitted
completely without ill effect.
</p>
<p class="para">
The <var class="filename">CREDITS</var> file lists the contributors and/or
maintainers of the extension in plain text format. The main purpose of
this file is generating the credits information for bundled extensions as
used by <a href="function.phpcredits.php" class="function">phpcredits()</a>. By convention the first line of
the file should hold the name of the extension, the second a comma
separated list of contributors. The contributors are usually ordered by the
chronological order of their contributions. In a <a href="http://pecl.php.net/" class="link external">» PECL</a> package,
this information is already maintained in <var class="filename">package.xml</var>,
for example. This is another file which can be omitted without ill effect.
</p>
<p class="para">
The <var class="filename">package.xml</var> file is specific to <a href="http://pecl.php.net/" class="link external">» PECL</a>-based
extensions; it is a metainformation file which gives details about an
extension's dependencies, authors, installation requirements, and other
tidbits. In an extension not being hosted in <a href="http://pecl.php.net/" class="link external">» PECL</a>, this file is
extraneous.
</p>
</div>
</div><?php manual_footer(); ?>