PROGRAMMING

m9/ PHP
REMEMBERS




Last update:   23-07-2021

Autoloader usage

Directory structure
 
httpclient/
    src/
    vendor/
    index.php
Composer initialization
 
composer init
Update composer.json file
 
"autoload": {
    "psr-4": {
        "minte9\httpclient\": "vendor/minte9/httpclient/src/"
    },
    "classmap": [
        "src/"
    ]
}
... 2 lines
 
Generate autoload files (vendor/composer/autoload*)
 
composer dump-autoload
View changes in files
 
autoload_classmap.php

    return array(
        'DssParser' => $baseDir . '/src/DssParser.php',
        'RapidapiParser' => $baseDir . '/src/RapidapiParser.php',
    );

autoload_psr4.php

return array(
    'minte9\httpclient\' => array($vendorDir . '/minte9/httpclient/src'),
);
... 3 lines
 
Replace your autoloader with composer autoloader
 
// index.php

require_once __DIR__ . '/vendor/autoload.php';

Questions    
Package

        A B C D E F
🔔
1/1