UA Parser - configuration and setup - no errors, no output

I am trying to get the UA Parser from here https://github.com/ua-parser/uap-php to work, but i seem to be missing something

path to my testpage (which is the sample usage page found here: https://github.com/ua-parser/uap-php, with a full user-agent string in place of the one in the sample)
API/lib/utils/create-ua-references.php

path to us parser code
API/lib/utils/UAParser

and the structure of the UAParser directory (see attachment)

I do not know if I have composer installed and I am fairly new to namespaces, so simple instructions on what I am doing wrong and how to fix it would be appreciated

EDIT:
NOTE: composer is not installed on the system and I cannot install it.

thanks
ua-parser-structure.png
LVL 25
James RodgersWeb Applications DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I do not know if I have composer installed...
Probably you do not have composer installed.  It's something you would know about because you actively have to use it.
https://getcomposer.org/

PHP Namespaces, despite having some fiddly implementation details are just a way of letting you avoid name collisions, much like the directory structure of a file system.  You can have "abc" in two different directories and you use the directory in conjunction with "abc" to disambiguate.

My recommendation: Take some time to learn composer - how to install it, how to use it, set up a few test cases to prove to yourself that you're doing it right.  Then come back to the application.
1
James RodgersWeb Applications DeveloperAuthor Commented:
Hi Ray,

thanks
for the quick reponse, however the site is on a shared server so I will be unable to install composer.

any suggestions on straight up simple parser for php implementations?
0
Ray PaseurCommented:
You might want to install composer locally on your own machine.  Just a thought.  It's almost a sine-qua-non requirement for web application development these days.

Can you please tell us a little more about what you want to get from UA-Parser?  Why is the user agent important to your application, etc.  There may be other solutions or maybe we can extract the important part out of the Github code.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

James RodgersWeb Applications DeveloperAuthor Commented:
I need the user agent details to extract
device
OS and
browser (type/version)

to create dropdowns for reporting filters

I am  going to loop over stored user agent strings to create unique table listings of the above information, these tables will then be used as the source for dropdown options on a reports page.

This way I will only show options for items that are actually in the listings rather than hard coding (e.g.: iPhone) in a dropdown and having the user select it then ask me why there are no results for iPhone, this also means that I will not have to manually add new device names etc.

I implemented the parser found here, and it worked
http://www.toms-world.org/blog/parseuseragentstring

but this does not appear to be as detailed as the other parsers I have tried to implement, i.e. the output did not identify the UA as iPhone
0
Ray PaseurCommented:
Yeah, it looks like anything that can deconstruct HTTP_USER_AGENT would meet most of the requirements.  You may be able to infer device from the OS data.

Here is that string for my desktop Windows 7 with Chrome (whitespace inserted).
Mozilla/5.0
(Windows NT 6.1)
AppleWebKit/537.36
(KHTML, like Gecko)
Chrome/44.0.2403.155
Safari/537.36

Here's the same for Firefox.
Mozilla/5.0
(Windows NT 6.1; rv:40.0)
Gecko/20100101
Firefox/40.0
0
James RodgersWeb Applications DeveloperAuthor Commented:
Any input on how I can get the original code to work, would much prefer the more recent code verion as it appears to have a larger selection of regex parsers

when I set  it up I  can get  the base parser php to load, but none of the other classes load, i think it   is related to the namespace

include  dirname(__FILE__) . "/UAParser/Parser.php";

Open in new window

Parser.php loads, but none of the other related classes load

in Parser.php there is
namespace UAParser;

use UAParser\Result\Client;

class Parser extends AbstractParser

Open in new window


but i dont see those items being loaded - i.e.: an echo statement on the Parser.php shows but an echo statement in Client.php is not showing
in the use statement

would it be possible/reasonable to to include all the files at the top of my test/implmentation page?
0
Ray PaseurCommented:
possible/reasonable to to include all the files...
That's why we use Composer!  It handles all of this stuff for you.  Seriously, you almost cannot work without it these days.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James RodgersWeb Applications DeveloperAuthor Commented:
damn... I am not the system controller, so that's a no go for now

I guess I am stuck with the simple version.


thanks for your input and advice, much appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.