summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2023-04-14 17:38:01 +1200
committerOlly Betts <olly@survex.com>2023-04-14 17:38:01 +1200
commite3b112c69ceed5c39cb07fa45a3ba62b27712679 (patch)
treec7c771a2b1d09862632facdf01ae10a05e2d61a4 /Doc
parent33f6a2d0b2c3d90b928f56ddfa599afe87903f76 (diff)
downloadswig-e3b112c69ceed5c39cb07fa45a3ba62b27712679.tar.gz
Remove support for PHP7
PHP7 security support ended 2022-11-28 so it doesn't make sense to include support for it in the SWIG 4.2.x release series.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/Manual/Php.html94
-rw-r--r--Doc/Manual/SWIG.html2
2 files changed, 32 insertions, 64 deletions
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index fad7f6a2f..815d99dce 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -51,12 +51,13 @@
<p>
-In this chapter, we discuss SWIG's support of PHP. Currently any PHP7 or PHP8
+In this chapter, we discuss SWIG's support of PHP. Currently any PHP8
release should work.
</p>
<p>
-Support for PHP7 was added in SWIG 3.0.11 and for PHP8 in 4.1.0.
+Support for PHP8 was added in SWIG 4.1.0.
+Support for PHP7 was added in SWIG 3.0.11 and removed in 4.2.0.
Support for PHP5 was removed in SWIG 4.0.0 and support for PHP4 was removed in
SWIG 1.3.37. There never was a PHP6 release.
</p>
@@ -76,13 +77,14 @@ available.
<p>
-To build a PHP extension, run swig using the <tt>-php7</tt> option as follows
-(<tt>-php</tt> is also supported and currently is an alias for <tt>-php7</tt>
-but prior to SWIG 4.0.0 it was an alias for <tt>-php5</tt>):
+To build a PHP extension, run swig using the <tt>-php</tt> option
+(you can also use <tt>-php7</tt> - PHP7 and PHP8 have a largely compatible C
+extension API, hence the same option name has been used for both). For
+example:
</p>
<div class="code"><pre>
-swig -php7 example.i
+swig -php example.i
</pre></div>
<p>
@@ -146,9 +148,9 @@ least work for Linux though):
<p>
To test the extension from a PHP script, you first need to tell PHP to
-load it. Assuming you're using PHP 7.2 or higher, the recommended (and
-simplest!) way to do this is to copy it to PHP's default extension directory
-and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
+load it. The recommended (and simplest!) way to do this is to copy it to
+PHP's default extension directory and add a line like this to the
+<tt>[PHP]</tt> section of <tt>php.ini</tt>:
</p>
<div class="code"><pre>
@@ -156,10 +158,9 @@ and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
</pre></div>
<p>
-PHP &lt; 7.2 doesn't support loading by just the module name, so you need
-to specify the filename of the module to be specified, which varies
-between platforms. And for any PHP version, if the module is not in PHP's
-default extension directory, you also need to specify the path, for example:
+If the module is not in PHP's default extension directory, you also need to
+specify the path, in which case you'll also need to deal with platform-specific
+naming - for example, on Linux:
</p>
<div class="code"><pre>
@@ -167,6 +168,14 @@ default extension directory, you also need to specify the path, for example:
</pre></div>
<p>
+but on Microsoft Windows you'd need to use:
+</p>
+
+<div class="code"><pre>
+ extension=/path/to/php_modulename.dll
+</pre></div>
+
+<p>
If you're using the PHP CLI SAPI it's possible (but not recommended) to use the
<a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to
load an extension at run time, by adding a line like this to the start of each
@@ -174,15 +183,17 @@ PHP script which uses your extension:
</p>
<div class="code"><pre>
- dl("/path/to/modulename.so"); // Load the module
+ dl("modulename"); // Load the module
</pre></div>
<p>
-But to do this portably you need to take into account that pathnames and the
-filename extension vary by platform, and for security reasons PHP no longer
-supports <tt>dl()</tt> when running PHP through a webserver. Overall it's
-better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
-above.
+Again, if the module isn't in PHP's default extension directory you'll also
+need to specify the path and deal with that varying by platform.
+</p>
+
+<p>
+For security reasons PHP no longer supports <tt>dl()</tt> when running PHP
+through a webserver, so this isn't an option there.
</p>
<H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2>
@@ -227,47 +238,6 @@ echo "E = " . E . "\n";
</pre>
</div>
-<p>
-There's one peculiarity of how constants work in PHP prior to PHP 8
-which it is useful to note (this is not specific to SWIG though) - if you try
-to use an undeclared constant, PHP will emit a warning (or a notice in PHP 7.1
-and earlier) and then expand the constant to a string version of the constant's
-name. Unfortunately it is easy to miss the warning message if you're using PHP
-in a webserver as it will probably end up in error.log or similar. PHP 8.0
-made this an error.
-</p>
-
-<p>
-For example,
-</p>
-
-<div class="code"><pre>
-%module example
-
-#define EASY_TO_MISPELL 0
-</pre>
-</div>
-
-<p>
-accessed incorrectly in PHP,
-</p>
-
-<div class="code">
-<pre>
-if(EASY_TO_MISPEL) {
- ...
-} else {
- ...
-}
-
-</pre>
-</div>
-
-<p>
-The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
-is treated as true by the if test, when the value of the intended constant
-would be treated as false!
-</p>
<H3><a name="Php_nn2_2">32.2.2 Global Variables</a></H3>
@@ -346,9 +316,7 @@ $c = bar(3.5); # Use default argument for 2nd parameter
<p>
SWIG generates PHP type declarations for function parameters and return
-types for PHP 8 and later (we don't try to support PHP 7's more limited type
-declarations and the generated wrappers compiled for PHP 7 will not have any
-type declarations).
+types for PHP 8 and later.
</p>
<p>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 3fb41e522..cc01d9e6c 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -128,7 +128,7 @@ Supported Target Language Options
-lua - Generate Lua wrappers
-octave - Generate Octave wrappers
-perl5 - Generate Perl 5 wrappers
- -php7 - Generate PHP 7 or later wrappers
+ -php7 - Generate PHP 8 or later wrappers
-python - Generate Python wrappers
-r - Generate R (aka GNU S) wrappers
-ruby - Generate Ruby wrappers