formatz / fz-hosting-symfony-bundle
FZ Hostings Symfony Bundle
Package info
gitlab.com/formatz/fz-hosting-symfony-bundle
Type:symfony-bundle
pkg:composer/formatz/fz-hosting-symfony-bundle
Requires
- php: >=8.0
- symfony/cache: ^5.4|^6.0|^7.0|^8.0
- symfony/config: ^5.4|^6.0|^7.0|^8.0
- symfony/console: ^5.4|^6.0|^7.0|^8.0
- symfony/dependency-injection: ^5.4|^6.0|^7.0|^8.0
- symfony/http-client: ^5.4|^6.0|^7.0|^8.0
- symfony/http-foundation: ^5.4|^6.0|^7.0|^8.0
- symfony/http-kernel: ^5.4|^6.0|^7.0|^8.0
- symfony/routing: ^5.4|^6.0|^7.0|^8.0
- symfony/yaml: ^5.4|^6.0|^7.0|^8.0
Requires (Dev)
- twig/twig: >=2.13
Suggests
- twig/twig: To insert the Matomo script with the fz_matomo_script() Twig function
Provides
None
Conflicts
None
Replaces
None
README
Installation
Install the bundle with composer
composer require formatz/fz-hosting-symfony-bundle
If you don't have Symfony Flex
Add the package config to `config/packages`
# config/packages/formatz_fz_hosting.yaml
formatz_fz_hosting:
api_key: '%env(resolve:FZ_HOSTING_API_KEY)%'
api_endpoint: '%env(resolve:FZ_HOSTING_API_ENDPOINT)%'
matomo:
url: '%env(FZ_MATOMO_URL)%'
site_id: '%env(FZ_MATOMO_SITE_ID)%'
token: '%env(FZ_MATOMO_TOKEN)%'
disable_cookies: true
disable_browser_feature_detection: true
Add env variable to `.env`
FZ_HOSTING_API_ENDPOINT=https://hostings.format-z.ch
FZ_HOSTING_API_KEY=changeme
FZ_MATOMO_URL=
FZ_MATOMO_SITE_ID=
FZ_MATOMO_TOKEN=
Send current versions
php bin/console fz-hosting:send-current-versions
Matomo
The bundle can serve the Matomo tracker through a first-party proxy (/_fz/core.js and /_fz/sync),
so ad blockers filtering the Matomo domain or the matomo.js / matomo.php names don't block the tracking.
The token stays on the server.
Enable the routes
Import the routes of the bundle
# config/routes/formatz_fz_hosting.yaml
formatz_fz_hosting:
resource: '@FormatzFzHostingBundle/Resources/config/routes.yaml'
If your firewall or access_control restricts the whole site, allow anonymous access to ^/_fz/.
Configure Matomo variables
Complete env variables in `.env`
FZ_MATOMO_URL=
FZ_MATOMO_SITE_ID=
FZ_MATOMO_TOKEN=
Matomo is disabled as long as the URL, the site ID or the token is empty: the proxy routes then return a 404 and nothing is added to the pages.
Insert the script
Add the Twig function in the <head> of your layout (it renders nothing when Matomo is disabled)
{{ fz_matomo_script() }}