whitecube/laravel-cookie-consent

@cookieconsentview is not rendered

Closed this issue · 10 comments

Hi, I used the readme to integrate this cookie consent using laravel 10 (latest),
however, the app.blade.php
results in just printing @cookieconsentview instead of integrating it.

The package is included in vendors.

Someone knows what I'm doning wrong?

Kind regards, raymanP

Hi, I am also looking for the answer to this problem (laravel 9)

Hi, it seems the Blade directive is not registered properly. Could you check if the package's Service Provider is loading as expected? Maybe dd() inside

protected function registerBladeDirectives()
... Thanks :)

Hi @toonvandenbos , registerBladeDirectives is not called.
I tried dd at CookiesServiceProvider::registerCookies, this is called.

Hi @raymanP, the registerBladeDirectives is defined in an auto-loaded service provider, whereas the registerCookies is called in another service provider you have to register. In other words, it seems that the package's autoloaded service provider is ironically not being loaded. Could you run composer update and check if the service provider is showing up in the discovered services providers list?

Hi @toonvandenbos , this is what I get from composer update:

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package laravelcollective/html is abandoned, you should avoid using it. Use spatie/laravel-html instead.
Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.  

  barryvdh/laravel-debugbar ................................................................. DONE
  intervention/image ........................................................................ DONE
  jackiedo/dotenv-editor .................................................................... DONE
  laravel/sail .............................................................................. DONE
  laravel/socialite ......................................................................... DONE
  laravel/tinker ............................................................................ DONE
  laravelcollective/html .................................................................... DONE
  mews/purifier ............................................................................. DONE
  nesbot/carbon ............................................................................. DONE
  nunomaduro/collision ...................................................................... DONE
  nunomaduro/termwind ....................................................................... DONE
  sentry/sentry-laravel ..................................................................... DONE
  socialiteproviders/manager ................................................................ DONE
  spatie/laravel-ignition ................................................................... DONE
  vedmant/laravel-feed-reader ............................................................... DONE
  whitecube/laravel-cookie-consent .......................................................... DONE
  yajra/laravel-datatables-oracle ........................................................... DONE

No security vulnerability advisories found.

whitecube/laravel-cookie-consent is in there, meaning the service provider should be loaded automatically. Could you dd inside its boot & register methods?

I found out, I had to copy also the files packages.php and services.php at bootstrap/cache/ to my server.
Now registerBladeDirectives is called.

And also I had to change
@cookieconsentscripts to @cookieconsentscripts() and so on, otherwise it was not active.
Is this a typo in the readme?

Now I get at @cookieconsentview():

\Component\Routing\Exception\RouteNotFoundException   PHP 8.2.17   laravel 10.48.4
Route [policy] not defined.

Has been fixed, seems to work now

Thank you very much for the help @toonvandenbos !!