{"id":21662374,"url":"https://github.com/prologuetech/laravel-big","last_synced_at":"2025-04-11T23:42:21.536Z","repository":{"id":57045177,"uuid":"95484559","full_name":"prologuetech/laravel-big","owner":"prologuetech","description":"Google BigQuery for Laravel","archived":false,"fork":false,"pushed_at":"2018-08-16T18:30:22.000Z","size":46,"stargazers_count":16,"open_issues_count":1,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-25T19:38:18.794Z","etag":null,"topics":["bigquery","google","google-bigquery","laravel","laravel-5-package","php"],"latest_commit_sha":null,"homepage":"http://prologuetechnology.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prologuetech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T20:01:46.000Z","updated_at":"2025-03-21T16:55:43.000Z","dependencies_parsed_at":"2022-08-24T04:11:12.195Z","dependency_job_id":null,"html_url":"https://github.com/prologuetech/laravel-big","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prologuetech%2Flaravel-big","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prologuetech%2Flaravel-big/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prologuetech%2Flaravel-big/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prologuetech%2Flaravel-big/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prologuetech","download_url":"https://codeload.github.com/prologuetech/laravel-big/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497902,"owners_count":21113982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","google","google-bigquery","laravel","laravel-5-package","php"],"created_at":"2024-11-25T10:15:57.855Z","updated_at":"2025-04-11T23:42:21.509Z","avatar_url":"https://github.com/prologuetech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google BigQuery for Laravel\n\nThis package aims to wrap laravel functionality around Google's BigQuery.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require prologuetech/big\n```\n\n## Setup\nPublish our config file into your application:\n\n``` bash\nphp artisan vendor:publish --provider=\"Prologuetech\\Big\\BigServiceProvider\"\n```\n\nYou should have a `config/prologue-big.php` file to configure defaults.\n\n### Laravel 5.4.x\nOlder versions of Laravel require you to add our big service provider to your application providers array in `config/app.php`:\n\n``` php\nProloguetech\\Big\\BigServiceProvider::class,\n```\n\nYou now have access to a familiar laravel experience, enjoy!\n\n## Google Authentication\nThe Google SDK supports Application Default Credentials (ADC) and thus this package does as well. You may leave your `auth_file` field inside of your config file `null` to use ADC. Credentials fetcher is not currently supported but may be added in the future.\n\nFor more information see the [adc docs](https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-php).\n\n## How to use\n\n### Configuration\n\nBy default we use the following global config options with BigQuery.\n\n```php\n$this-\u003eoptions = [\n    'useLegacySql' =\u003e false,\n    'useQueryCache' =\u003e false,\n];\n```\n\n### Tables\n\nWhen creating tables in BQ we automatically flip a Eloquent model schema for you. Let's cover an example of archiving data\nfrom our events table into BQ using laravel's chunk method.\n\n```php\n$datasetId = 'test';\n$tableId = 'events';\n\n// Create our BQ helper\n$big = new Big();\n\n// Create table, we will pass in a mocked model to mutate into BQ schema\n// Note: create table will only make a new table if it does not exist\n\n/** @var Google\\Cloud\\BigQuery\\Table $table */\n$table = $big-\u003ecreateFromModel($datasetId, $tableId, new Event());\n\n// Let's stream our events into BQ in large chunks\n// Note: notArchived() is a simple scope, use whatever scopes you have on your model\nEvent::notArchived()-\u003echunk(1000, function ($events) use ($big, $table) {\n    // Prepare our rows\n    $rows = $big-\u003eprepareData($events);\n\n    // Stream into BQ, you may also pass in any options with a 3rd param.\n    // Note: By default we use: 'ignoreUnknownValues' =\u003e true\n    $big-\u003einsert($table, $rows);\n\n    // Get our current id's\n    /** @var Illuminate\\Support\\Collection $events */\n    $ids = $events-\u003epluck('id')-\u003etoArray();\n\n    // Update these event's as processed\n    Event::whereIn('id', $ids)-\u003eupdate([\n        'system_processed' =\u003e 1\n    ]);\n});\n```\n\nThat's it! You now have a replica of your events table in BigQuery, enjoy!\n\n### Queries\n\nInstantiating ```Big``` will automatically setup a Google ServiceBuilder and give us direct access to ```BigQuery``` through\nour internals via ```$big-\u003equery```. However there are many helpers built into Big that make interacting with BigQuery a\npiece of cake (or a tasty carrot if you're into that kind of thing).\n\nFor example when running a query on BigQuery we must use the reload method in a loop to poll results. Big comes with a\nuseful method ```run``` so all you need to do is this:\n\n``` php\n$query = 'SELECT count(id) FROM test.events';\n\n$big = new Big();\n$results = $big-\u003erun($query);\n```\n\nWhen using ```run``` we automatically poll BigQuery and return all results as a laravel collection object for you so you\ncan enjoy your results as a refreshing cup of Laravel.\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprologuetech%2Flaravel-big","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprologuetech%2Flaravel-big","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprologuetech%2Flaravel-big/lists"}