You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You may want to use this router in a WordPress plugin. Great! But there's a problem when adding this router as composer dependency through composer and wpackagist.
For some reason I did not look into, autoload does not autoload the jetrouter files if the plugin is requested through wpackagist. This is most likely due to the fact that the entry point for a wordpress plugin is its main file, whereas people using autoload simply include the autoload.php file.
This is fine for plugins (case 1):
Your main WordPress project requires the plugin through wpackagist
Wpackagist adds the plugin in your plugins directory
Your plugin's main file loads the autoload.php file
All set
(case 2) If, however, you are declaring a plugin as a dependency for another plugin, under the circumstances outlined above you would need to require the plugin, then manually require the plugin's main file which then finally includes the plugin's autoload.php file with all its classes.
This can be done in a much easier and better way. When you normally require a dependency through composer, the dependency's dependencies are autoloaded and you don't have to do a thing.
As mentioned above, this does not happen when you required the jetrouter through wpackagist. It however works 100% fine through the standard packagist repository.
I am therefore now publishing this plugin through both wpackagist and packagist, so that it can be loaded through wpackagist as a root WordPress project dependency (case 2), or through packagist as a plugin or theme dependency (case 2)
TODO: write this in a more concise and understandable way and add this + steps to load through packagist in the README.
The text was updated successfully, but these errors were encountered:
You may want to use this router in a WordPress plugin. Great! But there's a problem when adding this router as composer dependency through composer and wpackagist.
For some reason I did not look into, autoload does not autoload the jetrouter files if the plugin is requested through wpackagist. This is most likely due to the fact that the entry point for a wordpress plugin is its main file, whereas people using autoload simply include the autoload.php file.
This is fine for plugins (case 1):
(case 2) If, however, you are declaring a plugin as a dependency for another plugin, under the circumstances outlined above you would need to require the plugin, then manually require the plugin's main file which then finally includes the plugin's autoload.php file with all its classes.
This can be done in a much easier and better way. When you normally require a dependency through composer, the dependency's dependencies are autoloaded and you don't have to do a thing.
As mentioned above, this does not happen when you required the jetrouter through wpackagist. It however works 100% fine through the standard packagist repository.
I am therefore now publishing this plugin through both wpackagist and packagist, so that it can be loaded through wpackagist as a root WordPress project dependency (case 2), or through packagist as a plugin or theme dependency (case 2)
TODO: write this in a more concise and understandable way and add this + steps to load through packagist in the README.
The text was updated successfully, but these errors were encountered: