About this project

Genlytics is a Composer package for Laravel that integrates Google Analytics 4 (GA4) into PHP applications. It provides a repository-pattern abstraction over the GA4 Data API, along with automatic caching, queued background jobs, and real-time report helpers. The package targets Laravel 9.x through 12.x and requires PHP 8.1+. A GA4 property and a Google Cloud service account with Analytics Data API access are prerequisites. Installation is done with `composer require zfhassaan/genlytics`. The package registers its service provider and facade automatically; developers may publish configuration and test stubs via Artisan commands. Environment variables control cache lifetime, background queue behavior, and real-time update intervals. Core usage revolves around constructing date periods, dimension arrays, and metric arrays, then passing them to `runReports()`, `runRealTime()`, or `runDimensionReport()` methods exposed through the `Genlytics` class or facade. The README highlights architectural choices such as dependency inversion, interface segregation, and event listeners for data fetch cycles. Cached responses reduce repeated API calls, while background jobs defer heavy queries away from the request thread. A small test suite accompanies the library, and example controllers demonstrate dashboard widgets, live visitor counts, and top-country breakdowns. Documentation pages cover installation steps, configuration options, migration from earlier versions, and troubleshooting.