Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.
This repository was archived by the owner on Feb 27, 2025. It is now read-only.

inefficient autoloader #34

@bkdotcom

Description

@bkdotcom

Installed via composer.

heartland-php's composer.json :

{
  "autoload":{
    "files": [
      "Hps.php"
    ]
  }
}

As a result my site now loads 184 files associated with the heartland-php sdk on every request (regardless of whether or not the request will even use the sdk, and regardless of what features I need)

the Hps.php file should only be necessary / used when composer isn't being used

Is there a reason heartland-php's composer.json doesn't define classmap rather than files?

ie

{
    "autoload": {
        "classmap": ["src/"]
    }
}

https://getcomposer.org/doc/04-schema.md#classmap

Files

If you want to require certain files explicitly on every request then you can use the files autoloading mechanism. This is useful if your package includes PHP functions that cannot be autoloaded by PHP.

(this isn't the case... the heartland-php sdk doesn't define any global functions. it only defines classes (and classes can be autoloaded)

Classmap

The classmap references are all combined, during install/update, into a single key => value array which may be found in the generated file vendor/composer/autoload_classmap.php. This map is built by scanning for classes in all .php and .inc files in the given directories/files.

You can use the classmap generation support to define autoloading for all libraries that do not follow PSR-0/4. To configure this you specify all directories or files to search for classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions