Giter Club home page Giter Club logo

Comments (7)

jubianchi avatar jubianchi commented on June 15, 2024

@jchamberlain I know the way the Core is initialized is not optimal for every use-cases but here are some thnigs you can test:

  • in the file where you require the composer autloader (i.e vendor/autoload.php) just require your own bootstrap (or the one from Laravel) before composer's autoloader so that your function will be defined first
  • Hoa/Core will always check if functions exist before defining them (example here)
  • Calling mb_*_encoding seems good if you are planning to use mbstring. Doing so you ensure the encoding is exactly what you expect it to be. Again, if you need to use a different value you can override this by calling mb_*_encoding after the require 'vendor/autoload.php';
  • setting the timezone in PHP is, to me, a prerequisite to run applications on a server.

99% of request to my app don't require Hoa, so I don't expect it to initialize until its needed.

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 ?

from core.

jchamberlain avatar jchamberlain commented on June 15, 2024

Thanks for your response.

  • Laravel relies on Composer (and uses the files array to load its own helpers), so I can't get it to run before Hoa. (Unless there's a way to change dependency order in Composer?)
  • Hoa, presumably because it's lower in the alphabet than Laravel, defines its functions first, so checking function_exists() doesn't help.
  • I don't have any complaints with mb_internal_encoding(), but rather that a dependency is unexpectedly and without asking changing PHP's configuration.
  • I agree that setting the timezone in PHP is a prerequisite, but setting it in php.ini is not. There are good reasons to use date_timezone_set(), and that very well may happen after dependencies are loaded.
  • My point about 99% is less about performance and more to highlight why I'm finding Hoa's initialization procedure so unexpected and unnecessary. If it didn't initialize until needed, none of this would be a problem because my functions would all be defined and configuration all entered (e.g., timezone).

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?

from core.

Hywan avatar Hywan commented on June 15, 2024

Few years ago, having Hoa\Core as a small set of files were logical and better for performances. Today, this is no longer the case (PHP is faster, OS I/O is faster, HDD is faster etc.). I am currently splitting Hoa\Core into Hoa\Event, Hoa\Consistency etc. and just one or two of them will be required all the time (like Hoa\Protocol —for hoa://— and Hoa\Consistency —for consistency— for instance).

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 _defined and function_exists before each declaration. So our responsibility is safe. Now, Laravel should do the same thing. Also, these helpers (because they are always only aliases/helpers) can disappear in a short time. They are no longer useful anymore. They are here for historical reasons. We are going to drop PHP5.4 and it will introduce a BC break (by nature) so we could drop these helpers in the same time.

Thoughts?

from core.

jubianchi avatar jubianchi commented on June 15, 2024

👍 with @Hywan seems a good plan :)

from core.

jchamberlain avatar jchamberlain commented on June 15, 2024

@hwyan, that sounds good!

from core.

Hywan avatar Hywan commented on June 15, 2024

@jchamberlain Please, see #96.

from core.

Hywan avatar Hywan commented on June 15, 2024

Problem solved since Hoa\Core has been split.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.