A minimalist example showing how to wire up Moodle’s PHP-8 router in a local/ plugin.
- Installs like any other local plugin.
- Demonstrates how to use the new routing system in Moodle 4.5+.
- Provides simple examples of a controller.
-
Clone into your Moodle tree:
cd /path/to/moodle/local git clone https://github.com/laurentdavid/moodle-local_routing.git router -
Install in Moodle via Site administration
▶️ Notifications. -
(Optional) Enable “clean” URLs with Apache:
Either copy the .htaccess file from the plugin root to your Moodle root or create
a new .htaccess file in your Moodle root with the following content:
```apacheconf
# in your Moodle root or local/router/.htaccess
FallbackResource /r.phpAnd ensure AllowOverride All in your original <Directory> block.
- Swagger UI:
https://<your-site>/admin/swaggerui.php - OpenAPI JSON:
https://<your-site>/r.php/api/rest/v2/openapi.json
- Test JSON controller:
https://<your-site>/local_routing/sample/worldYou should get a simpleHello, world!-style response.
All the installation steps, routing details, and shim setup live in Chapter 3 of this training: 03 – Creating Your Own Routes. 👉 See 03-Creating-Your-Own-Routes.md for the full walkthrough.