About
This is the installation and configuration of the dokuwiki development platform on Windows that we use.
We are not working with WSL or any docker anymore because it causes too much pain for little improvement. ie:
- slow. Docker with the last WSL2 is really, really slow if you don't work in WSL
- two environment to manage:
- two composer,
- two different EOL
- …
- file permission problem between linux and windows
- difficult to set up (IDEA does not support entirely WSL, phpunit does not recognize map drive, …)
- network problem between the virtual container and windows
This is a sort of keep it simple by staying with the smallest tech stack as possible.
Steps
Install php
The PHP version is the lowest supported by Dokuwiki which is 7.4.20 (See splitbrain/dokuwiki/blob/stable/.travis.yml) This is also the lowest version supported by webhosting provider such as OVH.
For the version 7.4.20:
- Optional as installed by default in Windows 11: Install the X86 version of Visual C++ Redistributable for Visual Studio 2012 (even on a X64 computer)
- Download php and unzip it under the root. Example: C:\php-7.4.2o-Win32-VC15-x64
- Copy the php-developement.ini to php.ini
- Test it
php.exe -i > phpinfo.txt
PATH Environment variable
Add in the PATH the php directory
Optional
Extension
- Change the php.ini configuration
; some compilation needs the whole path for the extension dir
; extension_dir = "c:/php-7.2.28-Win32-VC15-x64/ext"
; some compilation (ie apache.dll) does not need the extension dir (ie 7)
extension_dir = "ext"
[PHP]
; for image
extension=gd2
; for composer
extension=curl
extension=fileinfo
extension=mbstring
extension=pdo_sqlite
; openssl (ie fopen(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?)
extension=openssl
; for locale
extension=intl
You can check if they are loaded with:
php -m
and with apache via a phpinfo web page:
XDebug
This section is a summary of the article Xdebug for php 7.4
To enable Xdebug on a dokuwiki devel computer:
[Xdebug]
zend_extension = xdebug
# zend_extension=C:\php-7.4.20-Win32-VC15-x64\ext\php_xdebug-3.1.16-7.4-vc15-x86_64.dll
; enable the debugger
xdebug.mode=debug
; Xdebug 3 - default debugging port has changed from 9000 to 9003.
xdebug.client_port=9003
Phpunit
- Install phpunit in the project to have coding assistance as stated here
cd yourProject
wget -O phpunit.phar https://phar.phpunit.de/phpunit-7.phar
Package Manager
optional
Install
- pear (7.5.9)
Install Apache
Apache installation, virtual host and php configuration
Create the virtual host to the dokuwiki root.
Example:
<VirtualHost *:80>
DocumentRoot "d:/dokuwiki"
ServerName doku
DirectoryIndex index.php
ErrorLog "logs/doku.com-error.log"
CustomLog "logs/doku.com-access.log" common
<Directory "d:/dokuwiki/" >
Require all granted
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
</Directory>
</VirtualHost>
Dokuwiki
Clone Dokuwiki
You need to clone it in order to get the dokuwiki test class.
git clone git://github.com/splitbrain/dokuwiki.git .
Configuration
Go to: http://VitrualHost/install.php to configure it
- Enable ACL - Yes - to test logged in and logged out
- ACL Policy: Public
Go to the configuration manager:
- debug your code with compress disabled. You can verify your code still works with compress enabled with the JSLint online service
- Cache: Disable the whole render cache by setting the cache page time to -1. See Dokuwiki - Cache Dev configuration
- Verify that the index.php doesn't have a redirection.
- Don't set the basurl to be able to test with ngrok. (ie google metadata checking tool does not allow localhost)
Install Stale
Install Stale to stale the cache easily.
Because we are the authors, we clone it.
cd $DOKUWIKI\lib\plugins
git clone https://github.com/ComboStrap/stale
IDEA
See also the dokuwiki documentation
Go to Settings > Version Control > Directory Mapping to add the plugins git repository
Interpreter
Set the php interpreter to 7.1
Unit test
Phpunit Settings: To run individual test file on plugin:
- For Combostrap developer: you need to set the alternative bootstrap file to \plugins\combo\_test\bootstrap.php
- For General Dokuwiki development, you just need to set the phpunit.xml
Then:
- set the _test directory as Test Source. Context menu option Mark directory As Test Source Root
- A class/method: add the option –stderr to the test runner options to avoid PHPUnit_Framework_Error_Warning : Cannot modify header information - headers already sent by (output started at …php\pear\PHPUnit\Util\Printer.php:172)
- Change the running template
Library
Add Jquery as library:
- Settings (CTRL + ALT + S) > Languages & Frameworks > JavaScript > Libraries (Enabled or Download Jquery)
Browser
Disable the cache in devtool
Support
Call to undefined function dokuwiki\Utf8\mb_strtolower()
- Enable the mbstring extension in your php.ini
extension=mbstring
- And if you have the extension_dir setup, try to comment it
; extension_dir="ext"