0

I'm building a website with a WordPress ecosystem called Roots (Trellis + Bedrock + Sage). The new version of the Theme (Sage 9) uses Laravel 5.6 and Blade.

I've completed half of the beginners course in Laracasts and I think I understand their use of namespacing, aliases etc... However I successfully installed my first Vendor, Laravel Mobile Detect, via $ composer require riverskies/laravel-mobile-detect but I'm unable to use it because it seems I'm not including it properly.

In order to begin using it I have to add Riverskies\Laravel\MobileDetect\MobileDetectServiceProvider::class to config/app.php. However, there isn't one in Sage. Instead there is:

  • config/assets.php
  • config/theme.php
  • config/view.php

I assume this is because they're trying to provide more granular configuration files relevant to this theme. But regardless of which file I add it to the Vendors code (below) is not rendering.

Note: I have tried to install several Vendors and have encountered this same issue in each case. So this is not exclusive to the Vendor.

@desktop
  <h1>Test</h1>
@elsedesktop
  <h1>Test2</h1>
@enddesktop`

Due to my beginner's knowledge of Laravel: I'm not clear on the possible reasons this wouldn't work apart from the fact it appears to not be making my Vendor's code accessible to my Blade template files.

Can someone help me understand how to properly debug this?

karel
  • 5,489
  • 46
  • 45
  • 50
Spencer Hill
  • 1,043
  • 2
  • 15
  • 38

1 Answers1

0
  1. Install it using composer command. Hopefully you have already done it.

  2. Then add it in servce providers list in config/app.php

  3. Then Add 'MobileDetect' => Riverskies\Laravel\MobileDetect\Facades\MobileDetect::class in aliases array.

Then it will work properly. I have installed it & it's working perfectly. I think, you have missed this last step. I have followed guideline from this url https://github.com/riverskies/laravel-mobile-detect

For using it with sage, you can try it by adding

"require": {
        "mobiledetect/mobiledetectlib": "^2.8"
    }

inside your composer.json & reinstall it again. Check this url for more clear idea about it.

Jobayer
  • 1,221
  • 1
  • 14
  • 22
  • Thanks. Yes I installed it via Composer. Could you provide an example of what your aliases array file path is? – Spencer Hill Apr 23 '18 at 00:52
  • same file config/app.php. check below aliases array & add that 3rd point's line there. – Jobayer Apr 23 '18 at 00:55
  • As I mentioned in my post I don't have a config/app.php though. :/ – Spencer Hill Apr 23 '18 at 00:56
  • And adding it to my other config files produces no difference. – Spencer Hill Apr 23 '18 at 01:03
  • Yes, I have also checked their docs, have not found these configurable files. They have not provided this option to you. You can create an issue in their github repository(https://github.com/roots/sage/issues) for further assistance for it. – Jobayer Apr 23 '18 at 01:08