Skip to content

Commit 99521e3

Browse files
committed
wip
1 parent 5ca197c commit 99521e3

11 files changed

Lines changed: 804 additions & 197 deletions

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ The **Google Sheets Laravel Demo Project** is a demonstration application that s
1919
- Building data collection applications with Google Sheets as backend
2020
- Creating real-time dashboards that sync with spreadsheet data
2121

22-
## Copilot Environment Restrictions
23-
24-
⚠️ **CRITICAL**: Connections to Google APIs (such as `www.googleapis.com`) will fail in the Copilot environment due to firewall restrictions.
25-
26-
- **Google Sheets API calls will NOT work** in the Copilot development environment
27-
- This includes any attempt to use `php artisan serve` with real Google API integration
28-
- The application will fail when trying to connect to Google's servers from within Copilot
29-
- **Workaround**: Use mock data or skip Google API-dependent code when developing in Copilot
30-
- **Real API testing**: Must be done in GitHub Actions, local development environments, or production
31-
32-
**Development Strategy in Copilot**:
33-
1. Focus on UI development and Livewire component logic
34-
2. Use the existing mock patterns from the test suite (see `tests/Feature/ExampleTest.php`)
35-
3. Work with static/dummy data instead of live Google Sheets data
36-
4. Test API integration functionality via GitHub Actions or locally outside Copilot
37-
38-
**Note**: The project already includes proper mock testing patterns that demonstrate how to work around API connectivity issues.
39-
4022
## Project Structure
4123

4224
This Laravel 12 demo application uses a clean, modern architecture with the following key components:
@@ -112,144 +94,8 @@ POST_SPREADSHEET_ID=your_spreadsheet_id_here
11294
POST_SHEET_ID=Sheet1
11395
```
11496

115-
### 4. Application Setup
116-
117-
Install dependencies and generate application key:
118-
119-
```bash
120-
# Install PHP dependencies
121-
composer install
122-
123-
# Install JavaScript dependencies
124-
npm install
125-
126-
# Generate application encryption key
127-
php artisan key:generate
128-
129-
# Build frontend assets (for production)
130-
npm run build
131-
132-
# Or run development server (for development)
133-
npm run dev
134-
```
135-
136-
### 5. Run the Application
137-
138-
```bash
139-
# Start Laravel development server
140-
php artisan serve
141-
142-
# In another terminal, start Vite for asset compilation
143-
npm run dev
144-
```
145-
146-
**Important**: API functionality will not work in Copilot. For full testing, use GitHub Actions or a local environment.
147-
148-
## Testing
149-
150-
The project includes comprehensive testing strategies that work around API limitations:
151-
152-
### Running Tests
153-
154-
```bash
155-
# Run all tests
156-
php artisan test
157-
158-
# Run with coverage (if available)
159-
vendor/bin/phpunit --coverage-html coverage
160-
161-
# Lint code style
162-
composer run lint
163-
```
164-
165-
### Mock Testing Pattern
166-
167-
The project demonstrates proper mocking of Google Sheets API calls:
168-
169-
```php
170-
// Example from tests/Feature/ExampleTest.php
171-
Sheets::expects('spreadsheet->sheet->get')
172-
->andReturn(collect([
173-
['John Doe', 'Hello World', '2023-10-01'],
174-
['Jane Doe', 'Goodbye World', '2023-10-02'],
175-
]));
176-
177-
Sheets::expects('collection')
178-
->andReturn(collect([
179-
['name' => 'John Doe', 'message' => 'Hello World', 'created_at' => '2023-10-01'],
180-
['name' => 'Jane Doe', 'message' => 'Goodbye World', 'created_at' => '2023-10-02'],
181-
]));
182-
```
183-
184-
This pattern allows you to develop and test the application logic without requiring live API connections.
185-
186-
## Glossary of Project-Specific Terms
187-
188-
**Service Account** - `config/google.php`
189-
A Google Cloud service account that provides server-to-server authentication without requiring user interaction. The JSON credentials file contains the private key and client information.
190-
191-
**Livewire Component** - `app/Livewire/Sheets/`
192-
Laravel Livewire components that handle server-side rendering and real-time UI updates. This project uses standard PHP class components, not Volt functional components.
193-
194-
**POST_SPREADSHEET_ID** - Environment variable
195-
The unique identifier of the Google Spreadsheet, extracted from the spreadsheet URL. Format: `1SUNw7QzAMx-xXUwr5s-mJrZC9NGFRl4RqyzSL6CogkQ`
196-
197-
**POST_SHEET_ID** - Environment variable
198-
The name or ID of the specific sheet/tab within the spreadsheet where data will be written. Usually "Sheet1" for new spreadsheets.
199-
200-
**Sheets Facade** - `Revolution\Google\Sheets\Facades\Sheets`
201-
Laravel facade providing static access to Google Sheets operations like `get()`, `append()`, `update()`, and `collection()`.
202-
203-
**revolution/laravel-google-sheets** - Composer package
204-
Third-party Laravel package that simplifies Google Sheets API integration with fluent interface methods and Laravel-specific features.
205-
206-
**Flux Components** - `livewire/flux`
207-
Modern UI component library for Livewire applications, providing pre-built form elements, buttons, and layout components.
208-
209-
**GOOGLE_SERVICE_ENABLED** - Environment variable
210-
Boolean flag that enables service account authentication mode in the Google API client configuration.
211-
212-
**GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION** - Environment variable
213-
File path to the JSON credentials file downloaded from Google Cloud Console for service account authentication.
214-
215-
**append()** - `Sheets::spreadsheet()->sheet()->append()`
216-
Method that adds new rows to the end of a Google Sheet, used in the Form component to add new entries.
217-
218-
**get()** - `Sheets::spreadsheet()->sheet()->get()`
219-
Method that retrieves all data from a Google Sheet, used in the Posts component to display recent entries.
220-
221-
**collection()** - `Sheets::collection()`
222-
Helper method that transforms raw spreadsheet data into Laravel Collections with named keys based on header rows.
223-
224-
**majorDimension** - Google Sheets API parameter
225-
Controls whether data is organized by ROWS or COLUMNS. This project uses ROWS (default) for typical table-like data.
226-
227-
**spreadsheet()** - Fluent method
228-
Selects a specific Google Spreadsheet by ID for subsequent operations.
229-
230-
**sheet()** - Fluent method
231-
Selects a specific sheet/tab within the spreadsheet for data operations.
232-
233-
**Livewire Starter Kit** - Laravel scaffolding
234-
Modern Laravel frontend scaffolding that provides authentication, layouts, and component structure using Livewire 3.
235-
236-
**dispatch('postAdded')** - Livewire event
237-
Custom event dispatched when a new post is added, triggering real-time updates in the Posts component.
238-
239-
**#[Computed]** - Livewire attribute
240-
PHP attribute that marks a method as a computed property, automatically cached and updated when dependencies change.
241-
242-
**#[On('postAdded')]** - Livewire attribute
243-
PHP attribute that registers an event listener, causing the method to execute when the specified event is dispatched.
244-
245-
**#[Validate]** - Livewire attribute
246-
PHP attribute that defines validation rules for component properties, automatically validated on form submission.
247-
248-
**now()->toDateTimeString()** - Laravel helper
249-
Carbon method that returns the current timestamp in database-compatible format (Y-m-d H:i:s).
250-
25197
## About fakerphp/faker in Production
25298

25399
The package `fakerphp/faker` is installed using `require` (not `require-dev`) because it is needed by `app/Console/Commands/ResetCommand.php` to generate random names and sentences when resetting the spreadsheet.
254100
Although `fakerphp/faker` is typically used for development and testing, its use here is limited to generating dummy data via an artisan command.
255-
There are no security or performance issues with using it in production for this scenario.
101+
There are no security or performance issues with using it in production for this scenario.

0 commit comments

Comments
 (0)