XMF Cookbook
  • Introduction
  • XMF Cookbook
  • Basic Ingredients
    • Namespaces
    • Autoloading
    • Debugging
    • Forward Compatibility
  • Recipes
    • Introducing Module Helpers
    • Using the Permission Helper
      • Checking Permissions
      • Managing Item Permissions
    • Using the Session Helper
    • Using JSON Web Tokens
    • Altering Database Tables
    • Migrating a Module's Database
    • Loading Initial Data
    • Module Admin Pages
      • Hide and Seek with Icons
      • Standard Admin Pages
    • Manage Metadata
    • Highlighting Content
  • Reference
    • Assert
      • Assertions
    • Database
      • Migrate
      • TableLoad
      • Tables
        • Getting Started
        • Table Operations
        • Working with Columns
        • Working with Indexes
        • Changing Table Data
        • Interacting with the Work Queue
        • Error Info and Debugging
    • Debug
    • FilterInput
    • Highlighter
    • IPAddress
    • Jwt
      • JsonWebToken
      • KeyFactory
      • TokenFactory
      • TokenReader
    • Key
      • ArrayStorage
      • Basic
      • FileStorage
      • KeyAbstract
      • StorageInterface
    • Language
    • Metagen
      • Extracting Data
      • Applying Data
    • Module
      • Admin
      • Helper
      • Helper
        • AbstractHelper
        • Cache
        • GenericHelper
        • Permission
        • Session
    • ProxyCheck
    • Random
    • Request
    • StopWords
    • Uuid
    • Yaml
  • Credits
  • License:
  • Table of Content
Powered by GitBook
On this page
  1. Basic Ingredients

Autoloading

PreviousNamespacesNextDebugging

Last updated 6 years ago

You never need to use XoopsLoad or manually load a class file to use XMF. All XMF classes load automatically whenever you refer to them.

For example, consider the familiar XoopsRequest class.

XoopsLoad('xoopsrequest');
$cleanInput = XoopsRequest::getString('input', '');

XMF has a version of Request that is regularly synchronized with newer versions, and will be the definitive version starting with XOOPS 2.5.8. This is how the same code can look with XMF:

$input = Xmf\Request::getString('input', '');

You can combine this with the tips under , and expand to a few more input fields for a look at a more typical use case:

use Xmf\Request;

// ...

$input = Request::getString('input', '');
$id = Request::getInt('id', '');
$op = Request::getCmd('op', 'display');

Autoloading for the Xmf namespace is managed by a autoloader. The same autoloader also manages autoload for several libraries that XMF depends on. This autoloader will be standard in future XOOPS versions.

namespaces
PSR-4