whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
312 stars 37 forks source link

@cookieconsentview is not rendered #36

Closed raymanP closed 4 months ago

raymanP commented 5 months ago

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

ORN-Fox commented 5 months ago

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

toonvandenbos commented 5 months ago

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 https://github.com/whitecube/laravel-cookie-consent/blob/e8a363b2da8d3152ec8b4deb870a04394cbaa557/src/ServiceProvider.php#L64... Thanks :)

raymanP commented 4 months ago

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

toonvandenbos commented 4 months ago

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?

raymanP commented 4 months ago

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.
toonvandenbos commented 4 months ago

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

raymanP commented 4 months ago

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?

raymanP commented 4 months ago

Now I get at @cookieconsentview():

\Component\Routing\Exception\RouteNotFoundException   PHP 8.2.17   laravel 10.48.4
Route [policy] not defined.
raymanP commented 4 months ago

Has been fixed, seems to work now

raymanP commented 4 months ago

Thank you very much for the help @toonvandenbos !!