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

Enhancement: Use PSR-4 autoloader #604

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

localheinz
Copy link
Contributor

@localheinz localheinz commented Jul 3, 2022

This pull request

  • uses a PSR-4 autoloader

Follows #581.

@localheinz localheinz force-pushed the feature/autoloader branch 2 times, most recently from 0a7e50c to 0304314 Compare July 3, 2022 10:31
@kamil-tekiela
Copy link
Member

We could also use the PHP native autoloader, but we would have to get rid of the phpweb namespace as the standard one doesn't have a way to map phpweb to src as far as I know.

I think the News class should also use autoloader.

Copy link
Contributor

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes perfect sense to me. Thank you!

@kamil-tekiela
Copy link
Member

Something like this would also work:

set_include_path(__DIR__.'/src/'.get_include_path());

spl_autoload_register(static function (string $class): void {
    spl_autoload(str_replace("phpweb\\", "",$class));
});

@localheinz
Copy link
Contributor Author

@kamil-tekiela

I would not bother further optimizing the autoloading situation, especially in the light of #408.

@kamil-tekiela kamil-tekiela merged commit a83ae2f into php:master Jul 5, 2022
@localheinz localheinz deleted the feature/autoloader branch July 5, 2022 12:18
@localheinz
Copy link
Contributor Author

Thank you, @kamil-tekiela!

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

3 participants