Notes on Moodle Web App and Mobile App; Migrating old PHP sites to REST with Mobile App - ChatGPT
Sections in post
Section Summaries
1. Moodle Mobile + Web App Tech. Stacks
The Moodle mobile app is built with Cordova. It’s a hybrid Angular/Ionic application that leverages the Cordova framework to render HTML/CSS/JS within a native mobile container. This enables the app to access native device features via plugins while still using web technologies for UI. Moodle Developer Resources Moodle Docs
Framework | UI Technology | Native Access Mechanism | Resulting App Feel |
---|---|---|---|
Ionic + Cordova (Moodle App) | HTML + CSS + JS inside WebView | Cordova plugins for native features | Hybrid app, feels like a website in an app wrapper |
React Native / Flutter | Real native UI components (or Skia for Flutter) | Native modules/APIs for device features | Truly native UI and performance |
Tech Insights on Moodle App
- The core is built with Angular and Ionic, leveraging TypeScript. Moodle Developer Resources
- It uses Cordova to compile and access native features across platforms. Moodle Developer Resources Moodle Docs
- MoodleHQ even maintains custom forks of Cordova plugins such as
cordova-plugin-inappbrowser
andcordova-plugin-ionic-webview
, confirming its deep integration. Npm Git
Moodle has both PHP and Angular/Ionic in its ecosystem, but for different roles. Let’s clarify:
🔹 1. Moodle’s Core Web App (LMS platform)
- Written in PHP (with some JS sprinkled in).
- This is the classic Moodle web interface you access via a browser (teachers, admins, students).
- Lives on a web server, serving HTML pages generated by PHP.
- Still the main way most universities/schools use Moodle.
🔹 2. Moodle Mobile App (iOS/Android)
- Built with Angular + Ionic (TypeScript).
- Packaged with Cordova (so it runs inside a WebView).
- Not a clone of the entire Moodle web UI → instead it uses Moodle Web Services (REST APIs) exposed by the PHP backend.
- So the app talks to the PHP server (via JSON API calls) to fetch data (courses, assignments, messages).
🔹 3. How they fit together
- PHP = the “backend + web frontend”.
- Angular/Ionic = mobile client (in Cordova WebView).
- Mobile app does not run PHP code itself → it consumes web services provided by the Moodle PHP server.
✅ So the reality
- Moodle web interface → PHP (classic LMS).
- Moodle mobile app → Angular/Ionic in Cordova (calls PHP backend APIs).
- They wrote their own minimal web service framework in PHP.
- Admin UI in Moodle lets you enable/disable protocols, add tokens, and choose which functions are available.
- Documentation is auto-generated from PHP comments using Moodle’s internal docs system.
2. Providing REST API in PHP
PHP has a built-in SOAP extension (SoapServer
, SoapClient
) which lets you create a SOAP server that maps WSDL operations to PHP functions.
RestServer
. But REST is just HTTP + JSON, so you can do it manually.3. Migrating traditional PHP website (pure SSR, no API) to Modern Mobile + Web + REST API App
- Start with an existing PHP website with UI and business logic tangled together and no REST API.
- Separate UI from business logic so that core functions are in library PHP files which are invoked by UI templates for HTML rendering.
- Add a REST/JSON API layer either by using micro-framework like Slim or Lumen giving clean routing, middleware, authentication, JSON out-of-the-box OR write your own dispatcher.
- Secure it by adding API tokens / OAuth2 / JWT for authentication. Don’t expose raw PHP functions without access control.
- Write the mobile frontend app in React Native and Expo. Use fetch or axios to call the new REST API endpoints. Render data natively (Lists, Views, Forms, etc.)
- Bonus: reuse for web too. The same REST APIs can also serve a modern React/Next.js frontend later, if the group wants to replace the old PHP SSR UI.
- Tangled legacy code → hard to extract APIs.
- API load/performance issues: Old PHP apps often do DB queries directly in page scripts → fine for one user, but heavy API usage can overload the DB.
- Security & authentication.
- Inconsistent rules between UI and API.
- API versioning headaches: Once mobile apps are published, you can’t instantly update all clients. If API changes break old apps, users get errors. Solution is to version your APIs (/api/v1/courses, /api/v2/courses).
- Skill gap between PHP and mobile devs.
But if done carefully (like Moodle did), the payoff is huge → mobile apps + future-proof API architecture.
----------
4. Expanding on API load/performance issues between SSR web app and API mobile app
- SSR web app → fewer, heavier requests (HTML + CSS).
- API mobile app → many more, smaller requests (JSON), but potentially orders of magnitude more frequent.
- Use caching (Redis/Memcached, Moodle has MUC cache).
- Use batching (send all data in one JSON response instead of 10 calls).
- Use push notifications (instead of constant polling).
- Use rate limiting (protects backend if clients misbehave).
✅ So yes, old PHP websites can also overload the DB under high load, but API-based mobile apps amplify the load pattern because they encourage more frequent, granular calls.
---------
5. React and React Native were new/not around yet when Moodle picked AngularJS for its mobile app
- 2009–2010 → Cordova/PhoneGap launched.
- 2010 → AngularJS (Angular 1.x) released by Google, quickly gained traction.
- 2011–2012 → Moodle began work on Moodle Mobile app.
- 2013 → Moodle Mobile 1.0 released (AngularJS + Cordova).
- 2013 (May) → Facebook publicly released React (for the web).
- 2015 (March) → Facebook released React Native (for mobile).
So by the time Moodle had their first working mobile app (2013):
- React for web was brand new, not yet battle-tested.
- React Native didn’t even exist.
At that time:
- AngularJS was backed by Google.
- It was already widely adopted in the web community.
- It offered an MVC-like structure that PHP/JS developers could quickly learn.
- It was a better fit than jQuery spaghetti code for building a full app.
So Moodle’s choice was sensible and mainstream in 2012–2013.
✅ Bottom line:
When Moodle chose AngularJS + Cordova, React had just been open-sourced (not widely adopted), and React Native didn’t exist yet. So React wasn’t even on the table.
----------
6. React vs Angular (2025)
Aspect | React (2025) | Angular (2025) |
---|---|---|
Popularity | Vastly more popular, especially in startups | Niche in enterprise and regulated sectors |
Architecture | Library — flexible, requires third-party tools | Full framework — built-in features, opinionated |
Learning Curve | Gentle for JS beginners | Steep (TypeScript, RxJS, DI) |
Performance | Highly efficient with modern rendering systems | Optimized for scale (AOT, signals) |
Ecosystem | Huge, varied, community-driven | Cohesive, structured, Google-supported |
Best Fit (use case) | Dynamic UIs, SPAs, mobile-first apps | Large enterprise applications, enforced structure |
Final Thoughts
- React leads the web with unmatched flexibility, widespread use, and a vast ecosystem.
- Angular continues to thrive, particularly in enterprise-grade applications that benefit from its structure and built-in tooling.
- Both remain relevant in 2025, but React is the more commonly chosen framework for new, dynamic projects—while Angular shines when stability, structure, and long-term maintainability matter.
7. Performance comparison between PHP backend and Node Express backend
Startup overhead per request
- PHP (Moodle): Higher → bootstrap on every call.
- Node.js: Lower → app already initialized.
Concurrency model
- PHP: Each request handled by separate process/thread (depends on Apache/FPM). Scales OK, but higher memory cost.
- Node.js: Single-threaded event loop with async IO → handles many requests with lower memory.
Throughput
- Benchmarks usually show Node.js can handle more requests/sec than raw PHP under load, especially for API-heavy apps.
- BUT — for apps that are DB-bound (lots of SQL queries, joins, etc.), the database becomes the bottleneck, not PHP vs Node.
Caching
- Both can use Redis/Memcached to reduce DB load.
- Node.js makes in-process caching easy, while PHP needs external caching since each request is fresh.
- Moodle is not a “microservice” system → it’s a huge monolithic LMS.
- Rewriting in Node.js would be massive (decade-long effort).
- Most Moodle performance issues come from database queries and scaling architecture, not just PHP runtime.
- With OPcache, Redis caching, HTTP caching, Moodle can scale to millions of users.
- Yes, a Moodle REST API backend in PHP has more per-request overhead than a modern Node/Express backend.
- But, in real-world LMS usage:
- DB is the bottleneck.
- Caching solves most of the PHP statelessness inefficiency.
- Universities often run Moodle behind load balancers with horizontal scaling.
So Moodle’s PHP backend is “slower” in theory, but not a blocker in practice, given proper infra.
Comments
Post a Comment