Download the PHP package wpackagist-plugin/wpal-autoload without Composer
On this page you can find all versions of the php package wpackagist-plugin/wpal-autoload. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wpackagist-plugin/wpal-autoload
More information about wpackagist-plugin/wpal-autoload
Files in wpackagist-plugin/wpal-autoload
Package wpal-autoload
Short Description Wp Autoload with Namespaces (For better and clean plugin code using OOP)
License GPL3
Homepage https://github.com/mrimran/wpal-autoload
Informations about the package wpal-autoload
A plugin to write better plugin code (Written for Developers by a Developer)
A Plugin that is going facilitate use of Namespaces and making it easier to load files using Namespaces in other plugins.
It makes possible to get rid of include_once, require_once, include and require
as all of these methods make your code
look uglier and it becomes difficult to maintain that code. As to include other classes or functions properly you need
to append some paths and then have to mention the file name with the exact path.
This plugin needs you freedom of writing your code and organizing it based on your needed directory structure.
Guidlines
The only guidelines you need to follow are below:
- Namespace your classes and functions which you are separating so anything placed in
wp-content/plugins/TestPlugin/inc
should be namespaced asTestPlugin\inc
. Whereas anything placed inwp-content/plugins/TestPlugin/Inc
would be namespaced asTestPlugin\Inc
. - Filename should be same as of class name, but case doesn't matter because if Class name is
Test
and the file name istest.php
, the autoloader would still be able to load the correct file.
Usage
Now it's time to see how it'll help you to maintain your code if you are following the above guidelines to maintain
your code via Namespaces
.
In your main plugin file add below line:
Code to include classes and functions
Even without using the above code you can directly create instances of the classes, as the plugin would automatically include those files and will return the instance.
Installation
- Download the plugin and rename it to
wpal-autoload
orWpalAutoload
then place it inwp-content/plugins/
folder. - Login in to your admin and enable the plugin to use it.