PHP code example of moonwalkingbits / wordpress-autoloader

1. Go to this page and download the library: Download moonwalkingbits/wordpress-autoloader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moonwalkingbits / wordpress-autoloader example snippets




loader = new Moonwalking_Bits\Autoloader();

// Add as many namespace mappings as needed.
$autoloader->add_namespace_mapping( 'Namespace', '/path/to/classes' );

// Register the autoloader with the spl provided autoload queue.
spl_autoload_register( array( $autoloader, 'load_class' ) );



$autoloader->add_namespace_mapping( 'Namespace', '/path/to/classes' );

 // /path/to/classes/nested/class-test-class.php

namespace Namespace\Nested;

class Test_Class {}



$autoloader->add_namespace_mapping( '', '/path/to/classes' );