/psr4-wordpress-plugin

WordPress starter plugin with Support PSR-4 autoloading.

Primary LanguagePHPMIT LicenseMIT

PSR-4 WordPress Plugin

WordPress Standard Plugin with Support PSR-4 autoloading.

PSR-4: Autoloader

This PSR describes a specification for autoloading classes from file paths. It is fully interoperable, and can be used in addition to any other autoloading specification, including PSR-0. This PSR also describes where to place files that will be autoloaded according to the specification.

Structure

In the below you can see the folder structure and classes:

includes
    ├── Folder
    │   └── Test.php
    └── Folder2
        └── Test2.php

The example of the Test.php

namespace Folder;

class Test
{
    /**
     * @return string
     */
    public static function getHelloWorld()
    {
        return 'Hello World!';
    }
}

And you can run above class in your code with below command:

echo Folder\Test::getHelloWorld();