Download the PHP package viewtrender/php-youtube-testkit-laravel without Composer

On this page you can find all versions of the php package viewtrender/php-youtube-testkit-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-youtube-testkit-laravel

php-youtube-testkit-laravel

Laravel integration for mocking YouTube Data, Analytics, and Reporting APIs in tests.

Tests Latest Version PHP 8.3+

Overview

Laravel service provider, facades, and automatic container swaps for viewtrender/php-youtube-testkit-core. Supports three YouTube APIs:

When you call fake() on any API facade, the service provider replaces the Google Service container binding with a fake instance — controllers that type-hint the service receive the fake automatically.

Installation

The service provider is auto-discovered. To publish the config file:

Requirements

Setup

Register the real Google services in your AppServiceProvider:

Controllers can then type-hint any service:


Testing with Pest

Base Setup

Create a base test file or add to tests/Pest.php:

Import Factories


Factory Examples — Pest

Videos

Channels

Playlists

Playlist Items

Search Results

Subscriptions

Comments

Comment Threads

Activities

Captions

Channel Sections

Members (OAuth Required)

Membership Levels (OAuth Required)

I18n Languages

I18n Regions

Video Categories

Video Abuse Report Reasons

Thumbnails (Write-Only)

Watermarks (Write-Only)


Pagination

Two factories support multi-page responses via the HasPagination trait: YoutubePlaylistItems and YoutubeActivities. These are the Data API endpoints that return nextPageToken for iterating through large result sets.

Both expose two static methods that return array<FakeResponse> — spread them into fake([]) to queue all pages at once:

Method Purpose
paginated(pages, perPage) Auto-generate items with sensible defaults
pages(array) Explicit control over each page's items

Each factory also provides a named constructor for building individual items:

paginated() — auto-generated items

Generate multiple pages of fake items with a single call. Each page includes a nextPageToken except the last, and pageInfo reflects the total count.

Manual pagination loop

If your code paginates through results directly (e.g., in a job or service class), you can test the full loop:

pages() — explicit items per page

For full control over each page's contents, pass an array of pages, where each page is an array of item overrides. Use the named constructors (::playlistItem(), ::activity()) or pass raw override arrays.

You can also pass raw arrays to pages() — they'll be merged with fixture defaults:

Single page (no nextPageToken)

Passing one sub-array to pages() produces a single response with no nextPageToken — useful when you want explicit item control without multi-page behavior:

Testing pagination in Laravel jobs

A common pattern is testing a Laravel job that syncs all items from a paginated endpoint:


Testing with PHPUnit

Base Test Case

Video Tests

Channel Tests

Search Tests

Subscription Tests

Complete Feature Test Example


YouTube Analytics API

For on-demand metrics queries — dashboards, real-time stats, custom date ranges.

Base Test Case (Analytics)

Channel Analytics Tests


YouTube Reporting API

For bulk data exports — background jobs, historical data pipelines, scheduled reports.

Workflow: Create job → Poll for reports → Download CSV → Parse & upsert

Base Test Case (Reporting)

Reporting Job Tests

Complete Pipeline Test


Error Responses

Simulate API errors in your tests:


Assertions


Configuration


License

MIT


All versions of php-youtube-testkit-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
viewtrender/php-youtube-testkit-core Version ^0.6
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package viewtrender/php-youtube-testkit-laravel contains the following files

Loading the files please wait ...