moodle-php-direct

Execute PHP scripts on a Moodle server via SSH to access APIs and the database.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/tlambert03/microtutor-agent --skill moodle-php-direct
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moodle-php-direct
Source: https://github.com/tlambert03/microtutor-agent/tree/main/.claude/skills/moodle-php-direct
Command: npx skills add https://github.com/tlambert03/microtutor-agent --skill moodle-php-direct

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill enables executing PHP scripts directly on the Moodle server via SSH, allowing access to Moodle APIs and the database when REST permissions are insufficient or bulk/system tasks are needed. It reduces manual admin overhead and speeds up complex operations.

Core Features & Use Cases

  • Direct Server Script Execution: Run PHP scripts on the Moodle host to leverage Moodle APIs and the database.
  • Database & Admin Automation: Perform queries and changes not exposed via REST APIs.
  • Bulk Operations: Create or update multiple users, courses, or tokens in a single run.

Quick Start

Upload a PHP script to /var/www/html/moodle and execute it on the Moodle server using the provided script, for example to create a user.

Frequently Asked Questions about moodle-php-direct

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I execute PHP scripts directly on a Moodle server via SSH?

Direct PHP script execution on Moodle servers requires SSH access and involves uploading a script to the Moodle directory, then running it using the CLI_SCRIPT pattern with Moodle bootstrap to access APIs and the database. This bypasses REST API permission constraints for administrative tasks.

When should I use direct database queries instead of the Moodle REST API?

Use direct database queries when REST API permissions are insufficient, bulk operations span multiple resources, or debugging server-side logic is needed. Direct access allows complex queries and system-level tasks REST endpoints don't expose.

What are the security requirements for running PHP scripts on a Moodle server?

SSH script execution requires adherence to PHP CLI best practices, proper environment configuration, secure credential handling, and validation of input data. Scripts must follow the Moodle bootstrap pattern and respect database access controls to prevent unauthorized operations.

Can I automate bulk user and course operations on Moodle without API limitations?

Yes. Direct PHP scripts via SSH enable bulk creation, updates, and deletion of users and courses by accessing Moodle APIs and the database directly, eliminating per-request API throttling and permission constraints inherent in REST endpoints.

What prerequisites do I need to run PHP scripts on a Moodle server?

You need SSH access to the Moodle host, a valid SSH user account, knowledge of the Moodle directory structure, and familiarity with PHP CLI scripting and Moodle's database schema to write scripts that interact with $DB and the Moodle API.