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

On this page you can find all versions of the php package viewtrender/php-youtube-testkit-core. 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-core

php-youtube-testkit-core

Fake responses for YouTube Data API, Analytics API, and Reporting API in PHP tests.

Tests Latest Version PHP 8.3+

Overview

php-youtube-testkit-core lets you test code that uses google/apiclient without hitting real YouTube APIs. Queue fake responses, call Google services as normal, then assert which requests were made.

Supports three YouTube APIs:

Framework-agnostic — works with any PHP project and any test runner.

Installation

Requirements

Quick Start

YouTube Data API

YouTube Analytics API

YouTube Reporting API


YouTube Data API

Setting up fakes

Data API Factories

Factory Methods
YoutubeVideo list(), listWithVideos(), video(), empty(), notFound()
YoutubeChannel list(), listWithChannels(), channel(), empty(), notFound()
YoutubePlaylist list(), listWithPlaylists(), playlist(), empty()
YoutubePlaylistItems list(), listWithItems(), empty()
YoutubeSearchResult list(), listWithResults(), searchResult(), empty()
YoutubeCommentThreads list(), listWithThreads(), empty()
YoutubeComments list(), listWithComments(), empty()
YoutubeSubscriptions list(), listWithSubscriptions(), empty()
YoutubeActivities list(), listWithActivities(), empty()
YoutubeCaptions list(), listWithCaptions(), empty()

Custom items

Data API Assertions

Pagination

Test code that paginates through multi-page API responses. Pagination is provided by the HasPagination trait on YoutubePlaylistItems and YoutubeActivities — the Data API endpoints that return nextPageToken.

Both methods return array<FakeResponse> — spread them into fake([]):

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

Each factory also provides a named item constructor:

Auto-Generated Pages

Use paginated() to generate multiple pages of fake items:

Explicit Page Contents

Use pages() for full control over each page's items. You can pass raw override arrays or use the named constructors:

See docs/DATA_API.md for complete reference.


YouTube Analytics API

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

Setting up fakes

Analytics Factory Methods

Method Description
channelOverview() Channel-level aggregated metrics
dailyMetrics() Day-by-day breakdown
topVideos() Top performing videos
trafficSources() Traffic source breakdown
demographics() Age/gender viewer percentages
geography() Country-level metrics
deviceTypes() Device type breakdown
videoAnalytics() Per-video metrics
videoTypes() Metrics by content type

Channel Overview

Traffic Sources

Demographics

Content Types

See docs/ANALYTICS_API.md for complete metrics and dimensions reference.


YouTube Reporting API

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

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

Setting up fakes

Reporting Factories

Factory Methods
ReportingJob create(), list(), delete()
ReportingReport list(), get()
ReportingReportType list()
ReportingMedia download()

Creating a Job

Listing Jobs

Listing Reports

Downloading CSV Data

Common Report Types

Report Type ID Description
channel_basic_a2 Core channel metrics
channel_demographics_a1 Viewer age/gender
channel_device_os_a2 Device and OS distribution
channel_traffic_source_a2 Traffic source breakdown

See docs/REPORTING_API.md for complete reference.


Error Responses

Simulate API errors for any service:


Custom Responses

Build arbitrary responses with FakeResponse:


Preventing Stray Requests

Throw an exception when no fake response is queued:


Framework Integration

Register a callback that runs whenever fake() is called:

License

MIT


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

PHP Build Version
Package Version
Requires php Version ^8.3
google/apiclient Version ^2.15
google/apiclient-services Version *
guzzlehttp/guzzle Version ^7.4
guzzlehttp/psr7 Version ^2.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-core contains the following files

Loading the files please wait ...