Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend README to mention wpackagist autoload issue and packagist steps #7

Open
sformisano opened this issue Sep 1, 2016 · 0 comments

Comments

@sformisano
Copy link
Owner

sformisano commented Sep 1, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant