wppunk/wpautoload

Autoload your classes, interfaces and traits in WordPress

Installs: 138

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 3

Forks: 6

Open Issues: 3

Type:wordpress-autoload

v0.3 2021-10-14 13:37 UTC

README

Coverage Status CI/CD

WordPress Autoload

Autoload for your classes, interfaces and traits by WordPress Coding Standard.

How use?

composer require wppunk/wpautoload

Then add to the composer.json:

{
	 ...
	"extra": {
		"wp-autoload": {
			"\\Name\\Space\\": "src"
		}
	},
	...
}

Where key it is namespace and value it is the folder name.

Examples:

namespace My_Plugin

path src inside the plugin my-plugin.

Names for class, interface, trait:

wppunk\My_Plugin\Core\Awesome_Feature
wppunk\My_Plugin\Admin\Interface_Awesome_Feature
wppunk\My_Plugin\Front\Trait_Awesome_Feature

Paths:

.../wp-content/plugins/my-plugin/src/core/class-awesome-feature.php
.../wp-content/plugins/my-plugin/src/admin/interface-awesome-feature.php
.../wp-content/plugins/my-plugin/src/front/trait-awesome-feature.php