Giter Club home page Giter Club logo

Comments (11)

quentin389 avatar quentin389 commented on August 12, 2024

Hi, yes, moving away from php.ini browscap is a priority for me right now. I already have sped up GaretJax browscap, so it can fit my needs, and I'm going to migrate UserAgentInfo to use it in next two weeks (perhaps earlier, but I cannot guarantee that).

What about composer? Are there any substantial benefits of using it? Right now all you need to do is to put one require_once in the code and then you use the static class from anywhere in your code, so there isn't much need for autoloading here. Or could it perhaps help with using a cache with UserAgentInfo?
If you think it may be a good idea to use composer, I'm gonna look into it, but I don't like the idea of adding more bloat to the class if the benefit is not substantial.

from useragentinfo.

quentin389 avatar quentin389 commented on August 12, 2024

Moved request for browscap without php.ini to #5
This topic changed to a discussion about composer.

from useragentinfo.

CMCDragonkai avatar CMCDragonkai commented on August 12, 2024

Adding composer doesn't increase bloat. Composer does the autoloading for you if you follow PSR-0 namespacing. Otherwise a simple classmap is possible. It makes it easier to manage versions of releases.

from useragentinfo.

CMCDragonkai avatar CMCDragonkai commented on August 12, 2024

A programmartic conversion to json might be better.

from useragentinfo.

quentin389 avatar quentin389 commented on August 12, 2024

UserAgentInfo won't have any dependencies once browscap is migrated to phpbrowscap. It also doesn't require autoloading, it takes care of including its files. So the only reason to use composer would be for the updates.

I'm not against making it a composer package, but only if it can install updates from git, and if it can be made optional without forcing PHP 5.3+ requirement on the whole program.

I will have to test it and see if that can be achieved and if it will work well. If that will be the case then I will add composer.

That's going to have to wait until after the next release, because switching from get_browser() to phpbrowscap is a priority.

Btw. what do you mean by "A programmartic conversion to json might be better." ? Are you referring to the browscap.ini source file?

from useragentinfo.

CMCDragonkai avatar CMCDragonkai commented on August 12, 2024

Composer can do that fine. It can install from git, but I prefer using tagged releases instead of branches. Yep I would prefer Json mainly because of multilanguage support. I may need to use other programming languages.

from useragentinfo.

quentin389 avatar quentin389 commented on August 12, 2024

I'm not going to use JSON as a source file for any of the parsers. PHP array source file is the way to go, performance wise.

Loading large data structures into PHP memory takes a lot of time. So, when you decode JSON into array of PHP objects, or unserialize array of arrays - it takes time. This time becomes more and more significant the larger the thing you have to load into memory is.
However, when you use opcache on production servers, and that something you should definitely be doing, the PHP files you're using become already preloaded into the memory. That doesn't affect json source files behaviour, but when you use a php file with an array as a source for the data and use require to load it, the time it previously took to load all that data drops almost to zero.

You can see time differences even for fast classes like ua-parser - #7 (comment)
But the difference for phpbrowscap between loading from PHP file (as it's doing now) and JSON file is huuuuge.

So, as I take performance as priority in my projects, I will only use PHP files as the source data files.

from useragentinfo.

quentin389 avatar quentin389 commented on August 12, 2024

Migration from php.ini based get_browser() to phpbrowscap project is now completed.

from useragentinfo.

ammont avatar ammont commented on August 12, 2024

+1 for making it a composer package

from useragentinfo.

quentin389 avatar quentin389 commented on August 12, 2024

I will test the composer this weekend.

from useragentinfo.

ammont avatar ammont commented on August 12, 2024

It'll also manage your dependencies so you don't need to include the 3rd party libs.

from useragentinfo.

Related Issues (18)

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.