Skip to content

Refactor the autoload process in the bin script. #18

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

Merged
merged 1 commit into from
Jul 28, 2014

Conversation

nubs
Copy link

@nubs nubs commented May 9, 2014

This is a bit easier to understand I think.

It also uses require rather than include, so that failure to properly load the file terminates the script.

It also removes the error suppression which can silence unwanted errors (It will silence any errors that occur while parsing the related class (and any other files included in the process)).

@clue
Copy link
Owner

clue commented Jul 26, 2014

Thanks for your PR, @nubs 👍

I agree it makes sense to refactor this part and this change makes for a much cleaner code which is much easier to understand.

That being said, I personally feel looping over an array of possible file paths is a bit overkill. I would suggest using a normal conditional statement like this. Any thoughts?

@lyrixx
Copy link

lyrixx commented Jul 26, 2014

I prefer the if / else way too ;)

This is a bit easier to understand I think.

It also uses require rather than include, so that failure to properly
load the file terminates the script.

It also removes the error suppression which can silence unwanted errors
(It will silence any errors that occur while parsing the related class
(and any other files included in the process)).
@nubs
Copy link
Author

nubs commented Jul 27, 2014

Okay, I updated it using the linked code. I dislike the repeated path strings, but agree that a foreach loop is also kinda silly (especially since the list of paths isn't likely to grow anytime soon).

@clue
Copy link
Owner

clue commented Jul 28, 2014

Thanks for the feedback @lyrixx and thanks for the updated PR @nubs!

I agree that the duplicated path strings aren't quite ideal either. Tbh, personally, I don't think this is actually worth any further effort :) So until anybody comes up with a better solution, I think we're save to merge this as-is. Thanks guys, keep it up 👍

clue added a commit that referenced this pull request Jul 28, 2014
Refactor the autoload process in the bin script.
@clue clue merged commit 151ef3a into clue:master Jul 28, 2014
@lyrixx
Copy link

lyrixx commented Jul 28, 2014

We use to see this too:

if (file_exists($file = __DIR__ . '/../vendor/autoload.php')) {
    require $file
} elseif (file_exists($file = __DIR__ . '/../../../autoload.php')) {
    require $file
} else {
    fwrite(STDERR, 'ERROR: Composer dependencies not properly set up! Run "composer install" or see README.md for more details' . PHP_EOL);
    exit(1);
}

@johnknl
Copy link

johnknl commented Sep 25, 2015

I ran into this issue using the latest tag, per installation instructions. Maybe create a new tag and let Packagist update?

@clue
Copy link
Owner

clue commented Nov 17, 2015

Maybe create a new tag and let Packagist update?

Thanks for your patience, finally done :shipit:

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.

4 participants