Download the PHP package moirei/hogql without Composer
On this page you can find all versions of the php package moirei/hogql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package hogql
moirei/hogql
This PostHog (HogQL) Laravel Query Builder package enables you to interact with PostHog's HogQL API using Laravel's query builder. This package simplifies the process of building and executing analytical queries, allowing you to leverage Laravel's intuitive query syntax while working with PostHog's powerful data analytics platform.
Features
- Familiar Syntax: Use Laravel's query builder syntax to construct complex queries.
- Secure Access: Validate and restrict access to specific tables within PostHog.
- Seamless Integration: Execute queries and retrieve results directly from PostHog.
- Configurable Aliases: Easily map and alias table and column names for better readability.
- Eloquent Metrics: Easily integrate and use with moirei/eloquent-metrics.
Installation
Publish the config (optional).
Setup
After installation, you'll need to obtain your Product ID and a personal API key. This key will need atleast query:read
scope.
Update your .env
file with POSTHOG_PRODUCT_ID
and POSTHOG_API_TOKEN
accordingly.
Usage
Note: the
get()
operation always transforms the raw result. E.g. the query above returns a collection of arrays withevent_name
andevent_count
keys/values.
Extended usage
Get a DB Query Builder instance:
Start a query with select statement:
Referencing aliases:
Setup aliases in config:
Reference them via selects:
Get an Eloquent Query Builder instance:
Returns eloquent model instances.
Parse a query string:
Get the results of a string query:
Get the raw results of a string query:
Returns the raw original HogQLQueryResponse response.
With moirei/eloquent-metrics:
moirei/eloquent-metrics is Chartjs compatible.
Tests
Contribution Guidelines
Any pull requests or discussions are welcome. Note that every pull request providing new feature or correcting a bug should be created with appropriate unit tests.
License
The MIT License (MIT). Please see License File for more information.
All versions of hogql with dependencies
illuminate/contracts Version ^6|^7|^8|^9|^10|^10
illuminate/support Version ^6|^7|^8|^9|^10|^10
illuminate/database Version ^6|^7|^8|^9|^10|^10
greenlion/php-sql-parser Version ^4.6
laravel/helpers Version ^1.7