lesaff / statamic-useragent

User Agent addon for Statamic V2.x
4 stars 0 forks source link

Fatal Error Exception #1

Closed humanjpg closed 8 years ago

humanjpg commented 8 years ago

Hello

This add-on looks really good, so I'm keen to get it working :)

When I use the example list provided:

  Browser: {{ useragent:browser slugify="false" }}<br />
  Languages: {{ useragent:languages slugify="false" }}<br />
  Device: {{ useragent:device slugify="false" }}<br />
  Platform: {{ useragent:platform slugify="false" }}<br />
  Is Mobile?: {{ useragent:is_mobile }}<br />
  Is Tablet?: {{ useragent:is_tablet }}<br />
  Is Desktop?: {{ useragent:is_desktop }}<br />
  Is Robot?: {{ useragent:is_robot }}<br />
  Robot Name: {{ useragent:robot_name slugify="false" }}<br />

I get the following error:

Whoops, looks like something went wrong.

1/1
FatalErrorException in Useragent.php line 13:
Class 'Jenssegers\Agent\Agent' not found
in Useragent.php line 13

I also get it when using just {{ useragent:is_mobile }}

I tried running php please addon:refresh in terminal, but I then get a load of errors, which I believe I've seen before and are something to do with my terminal using a different version of php to my mamp server. I'm running php version 5.6.1.0 in mamp.

Thanks in advance

lesaff commented 8 years ago

@jpgdcl, have a look at your statamic/vendor folder and check to make sure that the addon dependency has been installed. If it's installed properly, you should see jenssegers folder in it (see screenshot below)

screen shot 2016-05-22 at 8 48 22 am

This code

<blockquote>
  Browser: {{ useragent:browser slugify="false" }}<br />
  Languages: {{ useragent:languages slugify="false" }}<br />
  Device: {{ useragent:device slugify="false" }}<br />
  Platform: {{ useragent:platform slugify="false" }}<br />
  Is Mobile?: {{ useragent:is_mobile }}<br />
  Is Tablet?: {{ useragent:is_tablet }}<br />
  Is Desktop?: {{ useragent:is_desktop }}<br />
  Is Robot?: {{ useragent:is_robot }}<br />
  Robot Name: {{ useragent:robot_name slugify="false" }}<br />
</blockquote>

should output like this

screen shot 2016-05-22 at 8 51 19 am

humanjpg commented 8 years ago

Ah, that would be it :) - No jessengers folder present, sadly.

Is there a way to run the php please addon:refresh command so it updates my mamp setup, rather than my OS?

humanjpg commented 8 years ago

I'm thinking of doing this: https://gist.github.com/kkirsche/5710272 and then running the php please addon:refresh command again...

But totally out of my depth, so not sure it's the right thing to do?

lesaff commented 8 years ago

Yeah, you could do that. That's what I did when I was still using MAMP pro

Run which php before and after the process to make sure you're on the right track.

humanjpg commented 8 years ago

For anyone with the same problem, this is not an ideal solution, but in the end I used the following workaround outlined below. Not ideal, but seemed to work for me.

Disclaimer: This is not my area of expertise whatsoever, so follow this at your own risk

A. Firstly, I followed this guide but for version php 5.6.10: https://gist.github.com/kkirsche/5710272 B. Then in terminal, I setup MAMP so its used as the default php rather than the OS:

  1. run cd on its own so you're in the root
  2. then run nano ~/.bash_profile
  3. Add the following line: export PATH="/Applications/MAMP/bin/php/php5.6.10/bin:$PATH" (replacing 5.6.10 with whatever version of php you're running / want to run
  4. Hit ctrl+x to save, then Y, and then hit Return
  5. Run source ~/.bash_profile
  6. Then when you run which php it should show: /Applications/MAMP/bin/php/php5.6.10/bin/php
  7. Running php -v command should now show: PHP 5.6.10 etc...

C. Then cd to your project directory and...

  1. add "lesaff/useragent": "*@dev" to statamic/composer.json’s require array if it isn't already there
  2. make sure you’re in the statamic folder then do php composer.phar update lesaff/useragent --no-dev —optimize-autoloader --prefer-dist

Props to https://github.com/jasonvarga and https://github.com/lesaff for their time and help.

humanjpg commented 8 years ago

OK, just tried this again on another Statamic instance. Found it didn't work. The workaround I had to use was to remove Useragent from my addons folder and the line from the statamic/composer.json file.

The Statamic upgrader then seem to install the dependencies in the CP... But then it just paused and I got was that the Statamic folder didn't exist. When I checked it just the composer stuff was in there.

So I dropped the statamic folder in manually from the latest version in the local/temp folder. Cleared the cache that did the trick.