This repository provides a BaseX add-on for DDEV. BaseX is a robust XML database engine and XQuery processor.
- Based on the
quodatum/basexhttpimage - Supports multiple architectures (amd64, arm64, arm/v7)
- Includes Saxon-HE for XSLT 3.0 support
- Includes XMLresolver
- Includes BaseX Web Application Server
Until this add-on is officially released, you can install it directly from the repository:
ddev add-on get davekopecek/ddev-basex
ddev restartThe BaseX server is available at:
- Web interface:
https://[project-name].ddev.site:9984 - Default admin credentials: username
adminwith passwordadmin
Note: The port (9984) is required as the standard HTTP/HTTPS ports (80/443) are used by the main web container.
To set a new admin password:
# Replace my-new-password with your desired password
ddev exec -s basex 'echo "my-new-password" | basex -cPASSWORD'
ddev restartThe add-on uses a combination of Docker volumes and project directories:
basex-data: Persists BaseX database databasex-webapp: For BaseX web applicationsbasex-repo: For BaseX package repository
basex/webapp/: For BaseX web applicationsbasex/repo/: For BaseX package repository
Store your BaseX applications and repositories in the project directories to maintain them in version control with your project.
Store your BaseX applications and repositories in your project's basex directory:
project-root/
├── basex/
│ ├── webapp/ # Store web applications here
│ └── repo/ # Store repositories here
Changes in these directories will be synced to the BaseX container on startup.
Create a new file basex/webapp/hello.xqm:
module namespace page = 'http://basex.org/examples/web-page';
declare %rest:path("hello")
%rest:GET
function page:hello() {
<response>
<message>Hello from BaseX!</message>
<time>{current-dateTime()}</time>
</response>
};
declare %rest:path("hello/{$name}")
%rest:GET
function page:hello-name($name) {
<response>
<message>Hello, {$name}!</message>
<time>{current-dateTime()}</time>
</response>
};Access your API at:
http://[project-name].ddev.site:9984/hellohttp://[project-name].ddev.site:9984/hello/YourName
Create a new file basex/repo/util.xqm:
module namespace util = 'http://example.org/util';
declare function util:greet($name as xs:string) as element(greeting) {
<greeting>
<to>{$name}</to>
<message>Welcome to BaseX!</message>
<timestamp>{current-dateTime()}</timestamp>
</greeting>
};
declare function util:format-date($date as xs:dateTime) as xs:string {
format-dateTime($date, "[D01] [MNn] [Y0001] at [H01]:[m01]:[s01]")
};# Create a database from an XML file
ddev exec -s basex "basex -c 'CREATE DB mydb /path/to/data.xml'"
# Create an empty database
ddev exec -s basex "basex -c 'CREATE DB mydb'"# Run a simple query
ddev exec -s basex "basex -c 'XQUERY db:open(\"mydb\")//title'"
# Run a query from a file
ddev exec -s basex "basex -i /path/to/query.xq"
# Interactive query session
ddev ssh -s basex
basex
> OPEN mydb
> XQUERY //title
> EXITTo SSH into the BaseX container:
ddev ssh -s basexTo run a command in the container without SSH:
ddev exec -s basex "your-command-here"To view BaseX logs:
# View BaseX logs
ddev logs -s basex
# Follow BaseX logs in real-time
ddev logs -s basex -fTo run the tests locally, you'll need:
- BATS (Bash Automated Testing System)
- DDEV installed and working
- Docker running
Install BATS:
# On MacOS
brew install bats-core
# On Linux
git clone https://github.com/bats-core/bats-core.git
cd bats-core
./install.sh /usr/localRun the tests:
# From the root of this repository
bats tests/test.bats
# To see more detailed output
bats --verbose-run tests/test.batsThe tests will:
- Create a temporary DDEV project
- Install the BaseX add-on
- Verify the BaseX server is running and accessible
- Clean up all test resources
Note: The tests may take a few minutes to run as they include starting DDEV and waiting for services to be ready.
Contributed and maintained by @davekopecek