I been testing is_mobile():
if (Agent::is_mobile())
{
$content = View::factory('mobile\viewname');
}
else
{
$content = View::factory('standard\viewname');
}
PHP profiler reports it taking up 2.25MB (after subtracting not using is_mobile() function in app) to return a true or false.
my browscap.cache file size is 433KB , is there plans to make this function take up less memory to do its checks? right now, I had to remove this function as it was just adding too much memory to my app.
The best solution is to configure PHP to use the browscap file, through php.ini (http://www.php.net/manual/en/misc.configuration.php#ini.browscap), which would allow the Agent class to use get_browser().
If that’s not possible, the Agent class allows you to simulate this function, and fetch the browscap file itself. As Jelmer said, you can replace this file by the light version by changing the configured URL.
However, by default this file is only fetched once a week. After fetching it’s parsed, optimized, and cached locally. To be able to do a lookup, this cache file needs to be loaded, which can account for the memory usage you see. It’s not kept in memory, so you should only see the memory usage if you check memory_get_peak_usage().
The result of a lookup is cached as well, so the next time the same browser comes along, the information is retrieved from cache, and the browscap cache is not loaded.