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

Mention need to require autoloader in hooks using functions #4187

Merged
merged 4 commits into from Aug 12, 2015
Merged

Mention need to require autoloader in hooks using functions #4187

merged 4 commits into from Aug 12, 2015

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Jun 27, 2015

Add a line and example to the documentation covering the need to require the autoloader file in order to use autoloaded files.

Addresses #4184

…ire the autoloader file in order to use autoloaded files
@alcohol
Copy link
Member

alcohol commented Jun 29, 2015

This will fail if autoload.php does not exist yet.

@jeskew
Copy link
Contributor Author

jeskew commented Jun 29, 2015

@alcohol As we discussed in #4184, I believe the existing disclaimer about the state of the autoloader being undetermined in pre-install and pre-update commands covers the possible non-existence of vendor/autoload.php. I could repeat part of that disclaimer in the bullet point added in this PR if you believe it's unclear.

@alcohol
Copy link
Member

alcohol commented Jun 30, 2015

Well at least set a good example :-(.
Don't use string interpolation, $vendorDir . '/autoload.php' is cleaner.

Also I think the current wording is a bit vague as to what kind of functions you are referring to. Remove the reiteration of the disclaimer (it's not necessary), and try to emphasise it's about functions that are normally only available via the files autoload attribute.

@jeskew
Copy link
Contributor Author

jeskew commented Jun 30, 2015

What phrasing would you suggest is more clear than 'functions defined outside of a class'?

I've always found interpolation to be cleaner, and since there's no performance difference between interpolation and concatenation, we'll have to agree to disagree on the aesthetics.

@alcohol
Copy link
Member

alcohol commented Jun 30, 2015

We can disagree on aesthetics, but we can agree on convention. So if you don't mind.

@alcohol
Copy link
Member

alcohol commented Jun 30, 2015

As for phrasing, maybe it's better to turn it around and simply make it more clear that "must be autoloadable via Composer's autoload functionality" does not mean that the autoloader is actually loaded, but merely that the same mechanism is used and that this only applies to the psr-0, psr-4 and classmap autoload types, not files.

@jeskew
Copy link
Contributor Author

jeskew commented Jul 16, 2015

@alcohol Were there any other changes you wanted to see made?

@alcohol
Copy link
Member

alcohol commented Jul 17, 2015

Well,

If a defined callback relies on functions defined outside of a class, the callback itself is responsible for loading the appropriate files, as no files beyond those required for psr-0, psr-4, and classmap autoloading are loaded during Composer commands.

could probably better be phrased as

Callbacks can only autoload classes from psr-0, psr-4 and classmap definitions. If a defined callback relies on functions defined outside of a class, the callback itself is responsible for loading the file containing these functions.

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

Successfully merging this pull request may close these issues.

None yet

2 participants