Skip to content

Commit 1a5babd

Browse files
author
Julien Pauli
committed
fixes, links
1 parent ac304f5 commit 1a5babd

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

Book/php7/build_system/building_extensions.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ shared objects can be created by explicitly passing ``--enable-EXTNAME=shared``
1515
``./configure``.
1616

1717
While static extensions will always be available, shared extensions need to be loaded using the ``extension`` or
18-
``zend_extension`` ini options [#]_. Both options take either an absolute path to the ``.so`` file or a path relative to
18+
``zend_extension`` ini options. Both options take either an absolute path to the ``.so`` file or a path relative to
1919
the ``extension_dir`` setting.
2020

2121
As an example, consider a PHP build compiled using this configure line::
@@ -33,7 +33,7 @@ directory. You can load both either by changing the ``extension_dir`` or by pass
3333
~/php-src> sapi/cli/php -dextension_dir=`pwd`/modules \
3434
-dzend_extension=opcache.so -dextension=gmp.so
3535

36-
During the ``make install`` step both ``.so`` files will be moved into the extension directory of your PHP installation,
36+
During the ``make install`` step, both ``.so`` files will be moved into the extension directory of your PHP installation,
3737
which you may find using the ``php-config --extension-dir`` command. For the above build options it will be
3838
``/home/myuser/myphp/lib/php/extensions/no-debug-non-zts-MODULE_API``. This value will also be the default of the
3939
``extension_dir`` ini option, so you won't have to specify it explicitly and can load the extensions directly::
@@ -49,9 +49,8 @@ As a rule of thumb, you'll use static linkage for the extensions bundled by PHP
4949
everything else. The reason is simply that building external extensions as shared objects is easier (or at least less
5050
intrusive), as you will see in a moment. Another benefit is that you can update the extension without rebuilding PHP.
5151

52-
.. [#] We'll explain the difference between a "normal" extension and a Zend extension later in the book. For now it
53-
suffices to know that Zend extensions are more "low level" (e.g. opcache or xdebug) and hook into the workings of
54-
the Zend Engine itself.
52+
.. note:: If you need informations about the difference between extensions and Zend extensions, you :doc:`may have a
53+
look at the dedicated chapter <../extensions_design/zend_extensions>`.
5554

5655
Installing extensions from PECL
5756
-------------------------------
@@ -358,7 +357,7 @@ We authors, use something like this in extensions of ours::
358357
359358
See?
360359

361-
Or, simpler (so better) is to use PHP_VERSION_ID which you are probably much more familiar about::
360+
Or, simpler (so better) is to use ``PHP_VERSION_ID`` which you are probably much more familiar about::
362361
363362
#if PHP_VERSION_ID >= 50600
364363

Book/php7/build_system/building_php.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ configuration header file ``main/php_config.h``.
142142

143143
Both utilities produce their results from the ``configure.in`` file (which specifies most of the PHP build process),
144144
the ``acinclude.m4`` file (which specifies a large number of PHP-specific M4 macros) and the ``config.m4`` files of
145-
individual extensions and SAPIs (as well as a bunch of other ``m4`` files).
145+
individual extensions and SAPIs (as well as a bunch of other `m4 files <http://www.gnu.org/software/m4/m4.html>`_).
146146

147147
The good news is that writing extensions or even doing core modifications will not require much interaction with the
148148
build system. You will have to write small ``config.m4`` files later on, but those usually just use two or three of the
@@ -211,8 +211,8 @@ your PHP binary contains using the ``-m`` option. For a default PHP 7.0 build th
211211
xmlreader
212212
xmlwriter
213213
214-
If you now wanted to stop compiling the CGI SAPI, as well as the tokenizer and sqlite3 extensions and instead enable
215-
opcache and gmp, the corresponding configure command would be::
214+
If you now wanted to stop compiling the CGI SAPI, as well as the *tokenizer* and *sqlite3* extensions and instead enable
215+
*opcache* and *gmp*, the corresponding configure command would be::
216216

217217
~/php-src> ./configure --disable-cgi --disable-tokenizer --without-sqlite3 \
218218
--enable-opcache --with-gmp
@@ -254,14 +254,15 @@ structures, will be reported.
254254

255255
``--enable-maintainer-zts`` enables thread-safety. This switch will define the ``ZTS`` macro, which in turn will enable
256256
the whole TSRM (thread-safe resource manager) machinery used by PHP. Writing thread-safe extensions for PHP is very
257-
simple, but only if make sure to enable this switch.
257+
simple, but only if make sure to enable this switch. If you need more information about thread safety and global
258+
memory management in PHP, you should read :doc:`the globals management chapter <../extensions_design/globals_management>`
258259

259260
On the other hand you should not use either of these options if you want to perform performance benchmarks for your
260261
code, as both can cause significant and asymmetrical slowdowns.
261262

262263
Note that ``--enable-debug`` and ``--enable-maintainer-zts`` change the ABI of the PHP binary, e.g. by adding additional
263-
arguments to many functions. As such shared extensions compiled in debug mode will not be compatible with a PHP binary
264-
built in release mode. Similarly a thread-safe extension is not compatible with a thread-unsafe PHP build.
264+
arguments to many functions. As such, shared extensions compiled in debug mode will not be compatible with a PHP binary
265+
built in release mode. Similarly a thread-safe extension (ZTS) is not compatible with a non-thread-safe PHP build (NTS).
265266

266267
Due to the ABI incompatibility ``make install`` (and PECL install) will put shared extensions in different directories
267268
depending on these options:
@@ -472,7 +473,7 @@ be::
472473
~/php-src> make test TESTS="Zend/ ext/reflection/ ext/standard/tests/array/"
473474

474475
We will take a more detailed look at the ``run-tests.php`` system later, in particular also talk about how to write your
475-
own tests and how to debug test failures.
476+
own tests and how to debug test failures. :doc:`See the dedicated tests chapter <../../tests/introduction>`.
476477

477478
Fixing compilation problems and ``make clean``
478479
----------------------------------------------

Book/php7/introduction.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Introduction
22
============
33

4-
This book is a collaborative effort between several PHP developers to better document and describe how PHP works
5-
internally.
4+
This book is a collaborative effort between several developers of the PHP language to better document and describe how
5+
PHP works internally.
66

77
There are three primary goals of this book:
88

@@ -37,10 +37,8 @@ make it translate to efficient CPU instructions so that you can design strong/fa
3737
* Hackers Delight
3838
* Write Great Code (2 Volumes)
3939

40-
.. note:: This book is Work-In-Progress and some chapters have not been written yet (in particular the ones on creating
41-
basic extensions and declaring functions), so if you're completely new to PHP extension development you'll have to
42-
wait until the remaining introductory chapters are published or start off with other
43-
`resources on the topic <https://wiki.php.net/internals/references>`_.
40+
.. note:: This book is Work-In-Progress and some chapters have not been written yet. We d'ont pay attention to a
41+
specific order, but add content as we feel.
4442

4543
The repository for this book is available on GitHub_. Please report issues and provide feedback on the `issue tracker`_.
4644

0 commit comments

Comments
 (0)