-
Notifications
You must be signed in to change notification settings - Fork 19
Hoa shouldn't initialize before being used #95
Comments
@jchamberlain I know the way the Core is initialized is not optimal for every use-cases but here are some thnigs you can test:
Initializing Hoa is a matter of some miliseconds I don't think you will even spot the difference when removing it. @Hywan could you give us some numbers here ? |
Thanks for your response.
Obviously I don't know Hoa well, so maybe its design is a necessity, but since I just need a way to evaluate user-supplied arithmetic I don't expect it to spill over into my other code like this. Is there any way it can be more self-contained and stick to its own namespace? |
Few years ago, having About the conflict between Laravel and Hoa… I am annoyed. Yes Hoa should not declare global constants and functions, that's why we are using Thoughts? |
👍 with @Hywan seems a good plan :) |
@hwyan, that sounds good! |
@jchamberlain Please, see #96. |
Problem solved since Hoa\Core has been split. |
I'm including
hoa/math
in my project so that I can evaluate arithmetic expressions (which is great, btw!). Unfortunately, this means Hoa'sCore.php
automatically initializes, unexpectedly polluting the global namespace and running code that can easily throw errors if run at the wrong time. Examples:mb_internal_encoding()
)._define()
andevent()
are defined, meaning I can't define them for my own project. I only realized this when I tried calling Laravel'sevent()
function.date
is called, so if your php.ini doesn't have a timezone set, you get an error.Because of your
composer.json
, all of this happens before any of my project's code has a chance to run, so the fact that Laravel defines anevent()
function doesn't matter, nor does its setting the timezone prevent Hoa from throwing an error.Could you put your constants in a class and your functions in Hoa's namespace? Then you could also do the initialization in the constructor and remove
Core.php
from the autoload "files" array. 99% of request to my app don't require Hoa, so I don't expect it to initialize until its needed.The text was updated successfully, but these errors were encountered: