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

Create Default HashId instance only if needed #86

Conversation

kohlerdominik
Copy link
Contributor

@kohlerdominik kohlerdominik commented Aug 18, 2023

Currently, on every boot, the "Default" HashId Instance is created. This is expensive, and in most use cases unneccessary, as this default is seldomly used, as far as I understand.

Further, when using an environment without Math-libraries for composer require veelasky/laravel-hashid (for example the Composer container), the php artisan package:discover command will fail, resulting in abortion of package discovery.

This change will delay the creation of the "Default" instance until it's required for the first time.

@kohlerdominik
Copy link
Contributor Author

kohlerdominik commented Aug 18, 2023

To reproduce the error while installing, you can use:
docker run -it --entrypoint ash composer -c "composer create-project laravel/laravel . && composer require veelasky/laravel-hashid"

Which will result in:
grafik

@kohlerdominik kohlerdominik changed the title Create Default HashId instance only, if needed Create Default HashId instance only if needed Aug 18, 2023
@veelasky veelasky merged commit 6c207c8 into veelasky:master Aug 19, 2023
17 checks passed
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