Skip to main content

Updating Autoloader Path

Every time you want to use a new class in your PHP project, first you need to include this class (using include or require language construct). When adding new functionality to Jadu Central this process would require changing core files that would be overwritten by a patch. Jadu Central can handle this inclusion using an autoloader.

If you are adding custom functionality into the jadu/custom directory as suggested throughout this guide you may need to add a path to the autoloader configuration.

To do this open /path/to/jadu/composer.json it will look similar

{
"repositories": [
{
"type": "composer",
"url": "https://repo-packagist.hq.jadu.net/jadu/"
}
],
"require": {
"php": ">=5.3.2",
"jadu/xfp-dependencies": "~3.5.1"
},
"require-dev": {
"phpunit/phpunit": "~4.5"
},
"autoload": {
"psr-0": {
"Jadu_Utilities": "jadu/utilities/"
},
"psr-4": {
"Jadu\\": "jadu/"
}
},
"scripts": {
"post-update-cmd": [
"npm install --quiet",
"node_modules/.bin/grunt prod"
],
"post-install-cmd": [
"npm install --quiet",
"node_modules/.bin/grunt prod"
]
},
"config": {
"platform": {
"php": "5.3.3"
}
}
}

Under the section psr-4 add a new line

"Jadu\\Custom\\": "jadu/custom/"

The autoload section after the change should look similar to:

  "autoload": {
"psr-0": {
"Jadu_Utilities": "jadu/utilities/"
},
"psr-4": {
"Jadu\\": "jadu/",
"Jadu\\Custom\\": "jadu/custom/"
}
},

Notify Jadu

It is important to inform Jadu of this change to composer.json, so that it is not overwritten by future patches built from Jadu's repository for your site.