diff --git a/dialogflow/README.md b/dialogflow/README.md new file mode 100644 index 0000000000..703be41a14 --- /dev/null +++ b/dialogflow/README.md @@ -0,0 +1,286 @@ +# Dialogflow: PHP Samples + +[![Open in Cloud Shell][shell_img]][shell_link] + +[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png +[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googlecloudplatform/php-docs-samples&page=editor&working_dir=dialogflow + +## Description + +This simple command-line application demonstrates how to invoke Dialogflow +API from PHP. + +## Before you begin +1. Follow the first 2 steps of [this quickstart](https://cloud.google.com/dialogflow-enterprise/docs/quickstart). +Feel free to stop after you've created an agent. + +2. This sample comes with a [sample agent](https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/dialogflow/resources/RoomReservation.zip) which you can use to try the samples with. Follow the instructions on [this page](https://dialogflow.com/docs/best-practices/import-export-for-versions) to import the agent from the [console](https://console.dialogflow.com/api-client). +> WARNING: Importing the sample agent will add intents and entities to your Dialogflow agent. You might want to use a different Google Cloud Platform Project, or export your Dialogflow agent before importing the sample agent to save a version of your agent before the sample agent was imported. + +3. Clone the repo and cd into this directory +``` + $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples + $ cd php-docs-samples/dialogflow +``` + +4. Follow [this guide](https://cloud.google.com/php/grpc) to install gRPC for PHP. + +5. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md). + Run `php composer.phar install` (if composer is installed locally) or `composer install` + (if composer is installed globally). + +## Samples + +``` +usage: php dialogflow.php command [options] [arguments] +``` + +### Detect intent (texts) +``` +DialogFlow API detect intent PHP sample with text inputs. + +Usage: + php dialogflow.php detect-intent-texts [options] ()... + +Examples: + php dialogflow.php detect-intent-texts -h + php dialogflow.php detect-intent-texts PROJECT_ID "hello" "book a meeting room" "Mountain View" + php dialogflow.php detect-intent-texts -s SESSION_ID PROJECT_ID "tomorrow" "10 AM" "2 hours" "10 people" "A" "yes" + +Command: + detect-intent-texts + +Arguments: + PROJECT_ID project/agent id. + texts array of text inputs separated by space. + +Options: + -s SESSION_ID identifier of DetectIntent session. defaults to random. + -l LANGUAGE_CODE language code of the query. defaults to "en-US". + +``` + +### Detect intent (audio) +``` +DialogFlow API detect intent PHP sample with audio file. + +Usage: + php dialogflow.php detect-intent-audio [options] + +Examples: + php dialogflow.php detect-intent-audio -h + php dialogflow.php detect-intent-audio PROJECT_ID resources/book_a_room.wav + php dialogflow.php detect-intent-audio -s SESSION_ID PROJECT_ID resources/mountain_view.wav + +Command: + detect-intent-audio + +Arguments: + PROJECT_ID project/agent id. + AUDIO_FILE_PATH path to audio file. + +Options: + -s SESSION_ID identifier of DetectIntent session. defaults to random. + -l LANGUAGE_CODE language code of the query. defaults to "en-US". + +``` + +### Detect intent (streaming) +``` +DialogFlow API detect intent PHP sample with audio file processed as an audio stream. + +Usage: + php dialogflow.php detect-intent-stream [options] + +Examples: + php dialogflow.php detect-intent-stream -h + php dialogflow.php detect-intent-stream PROJECT_ID resources/book_a_room.wav + php dialogflow.php detect-intent-stream -s SESSION_ID PROJECT_ID resources/mountain_view.wav + +Command: + detect-intent-stream + +Arguments: + PROJECT_ID project/agent id. + AUDIO_FILE_PATH path to audio file. + +Options: + -s SESSION_ID id of DetectIntent session. defaults to random. + -l LANGUAGE_CODE language code of the query. defaults to "en-US". + +``` + +### Context management +``` +DialogFlow API PHP samples showing how to manage contexts. + +Usage: + php dialogflow.php context-list [options] + php dialogflow.php context-create [options] + php dialogflow.php context-delete [options] + +Examples: + php dialogflow.php context-create -h + php dialogflow.php context-list -s SESSION_ID PROJECT_ID + php dialogflow.php context-create -s SESSION_ID -l 2 PROJECT_ID test-context-id + php dialogflow.php context-delete -s SESSION_ID PROJECT_ID test-context-id + +Commands: + session-entity-type-list + session-entity-type-create + session-entity-type-delete + +Arguments: + PROJECT_ID project/agent id. + CONTEXT_ID id of context. + +Options: + -s SESSION_ID id of DetectIntent session. required. + -l LIFESPAN_COUNT lifespan count of the context. + +``` + +### Intent management +``` +DialogFlow API PHP samples showing how to manage intents. + +Usage: + php dialogflow.php intent-list + php dialogflow.php intent-create [options] + php dialogflow.php intent-delete + +Examples: + php dialogflow.php intent-create -h + php dialogflow.php intent-list PROJECT_ID + php dialogflow.php intent-create PROJECT_ID "room.cancellation - yes" -t "cancel" -m "are you sure you want to cancel?" + php dialogflow.php intent-delete PROJECT_ID 74892d81-7901-496a-bb0a-c769eda5180e + +Commands: + intent-list + intent-create + intent-delete + +Arguments: + PROJECT_ID project/agent id. + DISPLAY_NAME display name of intent. + INTENT_ID id of intent. + +Options: + -t training_phrase_part training phrase. + -m message_texts message text for the agent's response when intent is detected. + +``` + +### Entity type management +``` +DialogFlow API PHP samples showing how to manage entity types. + +Usage: + php dialogflow.php entity-type-list + php dialogflow.php entity-type-create [options] + php dialogflow.php entity-type-delete + +Examples: + php dialogflow.php entity-type-create -h + php dialogflow.php entity-type-list PROJECT_ID + php dialogflow.php entity-type-create PROJECT_ID employee + php dialogflow.php entity-type-delete PROJECT_ID e57238e2-e692-44ea-9216-6be1b2332e2a + +Commands: + entity-type-list + entity-type-create + entity-type-delete + +Arguments: + PROJECT_ID project/agent id. + ENTITY_TYPE_DISPLAY_NAME display name of entity type. + ENTITY_TYPE_ID id of entity type. + +Option: + -k KIND kind of entity. KIND_MAP (default) or KIND_LIST + +``` + +### Entity management +``` +DialogFlow API PHP samples showing how to manage entities. + +Usage: + php dialogflow.php entity-list + php dialogflow.php entity-create []... + php dialogflow.php entity-delete + +Examples: + php dialogflow.php entity-create -h + php dialogflow.php entity-list PROJECT_ID e57238e2-e692-44ea-9216-6be1b2332e2a + php dialogflow.php entity-create PROJECT_ID e57238e2-e692-44ea-9216-6be1b2332e2a new_room basement cellar + php dialogflow.php entity-delete PROJECT_ID e57238e2-e692-44ea-9216-6be1b2332e2a new_room + +Commands: + entity-list + entity-create + entity-delete + +Arguments: + PROJECT_ID project/agent id. + ENTITY_TYPE_ID id of entity type. + ENTITY_VALUE value of the entity. + synonyms array of synonyms that will map to provided entity value. + +``` + +### Session entity type management +``` +DialogFlow API PHP samples showing how to manage session entity types. + +Usage: + php dialogflow.php session-entity-type-list [options] + php dialogflow.php session-entity-type-create [options] ()... + php dialogflow.php session-entity-type-delete [options] + +Examples: + php dialogflow.php session-entity-type-create -h + php dialogflow.php session-entity-type-list -s SESSION_ID PROJECT_ID + php dialogflow.php session-entity-type-create -s SESSION_ID PROJECT_ID room c d e f + php dialogflow.php session-entity-type-delete -s SESSION_ID PROJECT_ID room + +Commands: + session-entity-type-list + session-entity-type-create + session-entity-type-delete + +Arguments: + PROJECT_ID project/agent id. + ENTITY_TYPE_DISPLAY_NAME display name of entity type. + entity_value array of entity values separated by space. + +Options: + -s SESSION_ID id of DetectIntent session. required. + +``` + +## The client library + +This sample uses the [Google Cloud Client Library for PHP][google-cloud-php]. +You can read the documentation for more details on API usage and use GitHub +to [browse the source][google-cloud-php-source] and [report issues][google-cloud-php-issues]. + +## Troubleshooting + +If you get the following error, set the environment variable `GCLOUD_PROJECT` to your project ID: + +``` +[Google\Cloud\Core\Exception\GoogleException] +No project ID was provided, and we were unable to detect a default project ID. +``` + +If you have not set a timezone you may get an error from php. This can be resolved by: + + 1. Finding where the php.ini is stored by running `php -i | grep 'Configuration File'` + 1. Finding out your timezone from the list on this page: http://php.net/manual/en/timezones.php + 1. Editing the php.ini file (or creating one if it doesn't exist) + 1. Adding the timezone to the php.ini file e.g., adding the following line: `date.timezone = "America/Los_Angeles"` + +[google-cloud-php]: https://googlecloudplatform.github.io/google-cloud-php +[google-cloud-php-source]: https://github.com/GoogleCloudPlatform/google-cloud-php +[google-cloud-php-issues]: https://github.com/GoogleCloudPlatform/google-cloud-php/issues diff --git a/dialogflow/composer.json b/dialogflow/composer.json new file mode 100644 index 0000000000..5a0b126f5b --- /dev/null +++ b/dialogflow/composer.json @@ -0,0 +1,34 @@ +{ + "require": { + "google/cloud-dialogflow": "^0.1", + "symfony/console": "^3.1" + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Samples\\Dialogflow\\": "src/" + }, + "files": [ + "src/detect_intent_audio.php", + "src/detect_intent_stream.php", + "src/detect_intent_texts.php", + "src/entity_create.php", + "src/entity_delete.php", + "src/entity_list.php", + "src/entity_type_delete.php", + "src/entity_type_create.php", + "src/entity_type_list.php", + "src/intent_create.php", + "src/intent_delete.php", + "src/intent_list.php", + "src/context_create.php", + "src/context_delete.php", + "src/context_list.php", + "src/session_entity_type_create.php", + "src/session_entity_type_delete.php", + "src/session_entity_type_list.php" + ] + }, + "require-dev": { + "phpunit/phpunit": "~4" + } +} diff --git a/dialogflow/composer.lock b/dialogflow/composer.lock new file mode 100644 index 0000000000..f6b554d99f --- /dev/null +++ b/dialogflow/composer.lock @@ -0,0 +1,1959 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "ab06b1486203c55264a5876ec4bee390", + "packages": [ + { + "name": "firebase/php-jwt", + "version": "v5.0.0", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", + "reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": " 4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "time": "2017-06-27T22:17:23+00:00" + }, + { + "name": "google/auth", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/google/google-auth-library-php.git", + "reference": "8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/google-auth-library-php/zipball/8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71", + "reference": "8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0", + "guzzlehttp/guzzle": "~5.3.1|~6.0", + "guzzlehttp/psr7": "^1.2", + "php": ">=5.4", + "psr/cache": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.11", + "guzzlehttp/promises": "0.1.1|^1.3", + "phpunit/phpunit": "^4.8.36|^5.7", + "sebastian/comparator": ">=1.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Auth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Auth Library for PHP", + "homepage": "http://github.com/google/google-auth-library-php", + "keywords": [ + "Authentication", + "google", + "oauth2" + ], + "time": "2018-04-06T19:26:30+00:00" + }, + { + "name": "google/cloud-dialogflow", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/google-cloud-php-dialogflow.git", + "reference": "512a1a83726ab4c517fdb4eb40fa260d2eca843d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php-dialogflow/zipball/512a1a83726ab4c517fdb4eb40fa260d2eca843d", + "reference": "512a1a83726ab4c517fdb4eb40fa260d2eca843d", + "shasum": "" + }, + "require": { + "google/gax": "^0.31.0", + "google/proto-client": "^0.37" + }, + "require-dev": { + "google/cloud-core": "^1.14", + "phpdocumentor/reflection": "^3.0", + "phpunit/phpunit": "^4.8|^5.0" + }, + "suggest": { + "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google." + }, + "type": "library", + "extra": { + "component": { + "id": "cloud-dialogflow", + "path": "Dialogflow", + "entry": null, + "target": "GoogleCloudPlatform/google-cloud-php-dialogflow.git" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Dialogflow\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Cloud Dialogflow Client for PHP", + "time": "2018-04-16T18:09:56+00:00" + }, + { + "name": "google/gax", + "version": "0.31.2", + "source": { + "type": "git", + "url": "https://github.com/googleapis/gax-php.git", + "reference": "9043b2ae9ad3d1dfdc5d7f492496d2d3149e9caa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/gax-php/zipball/9043b2ae9ad3d1dfdc5d7f492496d2d3149e9caa", + "reference": "9043b2ae9ad3d1dfdc5d7f492496d2d3149e9caa", + "shasum": "" + }, + "require": { + "google/auth": "^1.2.0", + "google/protobuf": "^3.5.1", + "grpc/grpc": "^1.4", + "guzzlehttp/promises": "^1.3", + "guzzlehttp/psr7": "^1.2", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Api\\": "src/Api", + "Google\\ApiCore\\": "src/ApiCore", + "Google\\Cloud\\": "src/Cloud", + "Google\\Iam\\": "src/Iam", + "Google\\Jison\\": "src/Jison", + "Google\\LongRunning\\": "src/LongRunning", + "Google\\Rpc\\": "src/Rpc", + "Google\\Type\\": "src/Type", + "GPBMetadata\\Google\\": "metadata" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Google API Core for PHP", + "homepage": "https://github.com/googleapis/gax-php", + "keywords": [ + "google" + ], + "time": "2018-04-16T23:39:56+00:00" + }, + { + "name": "google/proto-client", + "version": "0.37.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/proto-client-php.git", + "reference": "fa092b339351fc38d204e39ea2e8bf9d4084bf86" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/proto-client-php/zipball/fa092b339351fc38d204e39ea2e8bf9d4084bf86", + "reference": "fa092b339351fc38d204e39ea2e8bf9d4084bf86", + "shasum": "" + }, + "require": { + "google/protobuf": "^3.4", + "php": ">=5.5" + }, + "require-dev": { + "google/gax": ">=0.25.0", + "phpunit/phpunit": "^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\": "src/Google/", + "GPBMetadata\\": "src/GPBMetadata/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Generated proto and gRPC classes for Google Cloud Platform in PHP", + "homepage": "https://github.com/googleapis/proto-client-php", + "keywords": [ + "google" + ], + "time": "2018-04-13T18:48:01+00:00" + }, + { + "name": "google/protobuf", + "version": "v3.5.2", + "source": { + "type": "git", + "url": "https://github.com/google/protobuf.git", + "reference": "b5fbb742af122b565925987e65c08957739976a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/protobuf/zipball/b5fbb742af122b565925987e65c08957739976a7", + "reference": "b5fbb742af122b565925987e65c08957739976a7", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.8.0" + }, + "suggest": { + "ext-bcmath": "Need to support JSON deserialization" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Protobuf\\": "php/src/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "php/src/GPBMetadata/Google/Protobuf" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "proto library for PHP", + "homepage": "https://developers.google.com/protocol-buffers/", + "keywords": [ + "proto" + ], + "time": "2018-03-06T03:54:18+00:00" + }, + { + "name": "grpc/grpc", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/grpc/grpc-php.git", + "reference": "741f59bac86c7b5e45818c8f2eec6980921bce23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grpc/grpc-php/zipball/741f59bac86c7b5e45818c8f2eec6980921bce23", + "reference": "741f59bac86c7b5e45818c8f2eec6980921bce23", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "google/auth": "v0.9" + }, + "suggest": { + "ext-protobuf": "For better performance, install the protobuf C extension.", + "google/protobuf": "To get started using grpc quickly, install the native protobuf library." + }, + "type": "library", + "autoload": { + "psr-4": { + "Grpc\\": "src/lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "gRPC library for PHP", + "homepage": "https://grpc.io/", + "keywords": [ + "rpc" + ], + "time": "2018-03-28T22:54:08+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.3.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-03-26T16:33:04+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "time": "2016-08-06T20:24:11+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf", + "reference": "d4bb70fa24d540c309d88a9d6e43fb2d339b1fbf", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com/", + "time": "2018-04-03T05:22:50+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.4.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "9cf7c2271cfb89ef9727db1b740ca77be57bf9d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/9cf7c2271cfb89ef9727db1b740ca77be57bf9d7", + "reference": "9cf7c2271cfb89ef9727db1b740ca77be57bf9d7", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com/", + "time": "2018-04-03T05:22:50+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com/", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-01-30T19:27:44+00:00" + } + ], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14T21:17:01+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org/", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-10T14:09:06+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.7.5", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com/" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-02-19T10:16:54+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-10-06T15:47:00+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2017-11-27T13:52:08+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26T11:10:40+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.12", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-12-04T08:55:13+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "4.8.36", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", + "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.2.2", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.3", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.8.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2017-06-21T08:07:12+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-10-02T06:51:40+00:00" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29T09:50:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2017-05-22T07:24:03+00:00" + }, + { + "name": "sebastian/environment", + "version": "1.3.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-08-18T05:49:44+00:00" + }, + { + "name": "sebastian/exporter", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-06-17T09:04:28+00:00" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12T03:26:01+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-10-03T07:41:43+00:00" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21T13:59:46+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.4.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "a42f9da85c7c38d59f5e53f076fe81a091f894d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/a42f9da85c7c38d59f5e53f076fe81a091f894d0", + "reference": "a42f9da85c7c38d59f5e53f076fe81a091f894d0", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com/", + "time": "2018-04-03T05:14:20+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-01-29T19:49:41+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/dialogflow/dialogflow.php b/dialogflow/dialogflow.php new file mode 100644 index 0000000000..9354641d2d --- /dev/null +++ b/dialogflow/dialogflow.php @@ -0,0 +1,450 @@ +add((new Command('detect-intent-texts')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.') + ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', 'en-US') + ->addArgument('texts', InputArgument::IS_ARRAY | InputArgument::REQUIRED, + 'Text inputs.') + ->setDescription('Detect intent of text inputs using Dialogflow.') + ->setHelp(<<%command.name% command detects the intent of provided text +using Dialogflow. + + php %command.full_name% PROJECT_ID [-s SESSION_ID] + [-l LANGUAGE-CODE] text [texts ...] +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $languageCode = $input->getOption('language-code'); + $texts = $input->getArgument('texts'); + detect_intent_texts($projectId, $texts, $sessionId, $languageCode); + }) +); + +// detect audio intent command +$application->add((new Command('detect-intent-audio')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.') + ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', 'en-US') + ->addArgument('path', InputArgument::REQUIRED, 'Path to audio file.') + ->setDescription('Detect intent of audio file using Dialogflow.') + ->setHelp(<<%command.name% command detects the intent of provided audio +using Dialogflow. + + php %command.full_name% PROJECT_ID [-s SESSION_ID] + [-l LANGUAGE-CODE] AUDIO_FILE_PATH +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $languageCode = $input->getOption('language-code'); + $path = $input->getArgument('path'); + detect_intent_audio($projectId, $path, $sessionId, $languageCode); + }) +); + +// detect stream intent command +$application->add((new Command('detect-intent-stream')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session. Defaults to random.') + ->addOption('language-code', 'l', InputOption::VALUE_REQUIRED, + 'Language code of the query. Defaults to "en-US".', 'en-US') + ->addArgument('path', InputArgument::REQUIRED, 'Path to audio file.') + ->setDescription('Detect intent of audio stream using Dialogflow.') + ->setHelp(<<%command.name% command detects the intent of provided text +using Dialogflow. + + php %command.full_name% PROJECT_ID -s SESSION_ID + -l LANGUAGE-CODE AUDIO_FILE_PATH +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $languageCode = $input->getOption('language-code'); + $path = $input->getArgument('path'); + detect_intent_stream($projectId, $path, $sessionId, $languageCode); + }) +); + +// list intent command +$application->add((new Command('intent-list')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->setDescription('List intents.') + ->setHelp(<<%command.name% command lists intents. + + php %command.full_name% PROJECT_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + intent_list($projectId); + }) +); + +// create intent command +$application->add((new Command('intent-create')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('display-name', InputArgument::REQUIRED, + 'Display name of intent.') + ->addOption('training-phrases-parts', 't', InputOption::VALUE_REQUIRED | + InputOption::VALUE_IS_ARRAY, 'Training phrases.') + ->addOption('message-texts', 'm', + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'Message texts for the agent\'s response when the intent is detected.') + ->setDescription('Create intent of provided display name.') + ->setHelp(<<%command.name% command creates intent of provided display name. + + php %command.full_name% PROJECT_ID DISPLAY_NAME -t training_phrase_part + [-t trainining_phrase_part ...] -m message_text [-m message_text ...] +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $displayName = $input->getArgument('display-name'); + $traingPhrases = $input->getOption('training-phrases-parts'); + $messageTexts = $input->getOption('message-texts'); + intent_create($projectId, $displayName, $traingPhrases, $messageTexts); + }) +); + +// delete intent command +$application->add((new Command('intent-delete')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('intent-id', InputArgument::REQUIRED, 'ID of intent.') + ->setDescription('Delete intent of provided intent id.') + ->setHelp(<<%command.name% command deletes intent of provided intent id. + + php %command.full_name% PROJECT_ID INTENT_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $intentId = $input->getArgument('intent-id'); + intent_delete($projectId, $intentId); + }) +); + +// list entity type command +$application->add((new Command('entity-type-list')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->setDescription('List entity types.') + ->setHelp(<<%command.name% command lists entity types. + + php %command.full_name% PROJECT_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + entity_type_list($projectId); + }) +); + +// create entity type command +$application->add((new Command('entity-type-create')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('display-name', InputArgument::REQUIRED, + 'Display name of the entity.') + ->addOption('kind', 'k', InputOption::VALUE_REQUIRED, + 'Kind of entity. KIND_MAP (default) or KIND_LIST', EntityType_Kind::KIND_MAP) + ->setDescription('Create entity types with provided display name.') + ->setHelp(<<%command.name% command creates entity type with provided name. + + php %command.full_name% PROJECT_ID DISPLAY_NAME -k KIND +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $displayName = $input->getArgument('display-name'); + $kind = $input->getOption('kind'); + entity_type_create($projectId, $displayName, $kind); + }) +); + +// delete entity type command +$application->add((new Command('entity-type-delete')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') + ->setDescription('Delete entity types of provided entity type id.') + ->setHelp(<<%command.name% command deletes entity type of provided id. + + php %command.full_name% PROJECT_ID ENTITY_TYPE_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $entityTypeId = $input->getArgument('entity-type-id'); + entity_type_delete($projectId, $entityTypeId); + }) +); + +// list entity command +$application->add((new Command('entity-list')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') + ->setDescription('List entities of provided entity type id.') + ->setHelp(<<%command.name% command lists entities of provided entity type id. + + php %command.full_name% PROJECT_ID ENTITY_TYPE_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $entityTypeId = $input->getArgument('entity-type-id'); + entity_list($projectId, $entityTypeId); + }) +); + +// create entity command +$application->add((new Command('entity-create')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') + ->addArgument('entity-value', InputArgument::REQUIRED, 'Value of the entity.') + ->addArgument('synonyms', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + 'Synonyms that will map to provided entity value.') + ->setDescription('Create entity value for entity type id.') + ->setHelp(<<%command.name% command creates entity value for entity type id. + + php %command.full_name% PROJECT_ID ENTITY_TYPE_ID ENTITY_VALUE [synonyms ...] +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $entityTypeId = $input->getArgument('entity-type-id'); + $entityValue = $input->getArgument('entity-value'); + $synonyms = $input->getArgument('synonyms'); + entity_create($projectId, $entityTypeId, $entityValue, $synonyms); + }) +); + +// delete entity command +$application->add((new Command('entity-delete')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addArgument('entity-type-id', InputArgument::REQUIRED, 'ID of entity type.') + ->addArgument('entity-value', InputArgument::REQUIRED, 'Value of the entity.') + ->setDescription('Delete entity value from entity type id.') + ->setHelp(<<%command.name% command deletes entity value from entity type id. + + php %command.full_name% PROJECT_ID ENTITY_TYPE_ID ENTITY_VALUE +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $entityTypeId = $input->getArgument('entity-type-id'); + $entityValue = $input->getArgument('entity-value'); + entity_delete($projectId, $entityTypeId, $entityValue); + }) +); + +// list context command +$application->add((new Command('context-list')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->setDescription('List contexts.') + ->setHelp(<<%command.name% command lists contexts. + + php %command.full_name% PROJECT_ID -s SESSION_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + context_list($projectId, $sessionId); + }) +); + +// create context command +$application->add((new Command('context-create')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->addArgument('context-id', InputArgument::REQUIRED, 'ID of the context.') + ->addOption('lifespan-count', 'c', InputOption::VALUE_REQUIRED, + 'Lifespan count of the context. Defaults to 1.', 1) + ->setDescription('Create context of provided context id.') + ->setHelp(<<%command.name% command creates context of provided context id. + + php %command.full_name% PROJECT_ID -s SESSION_ID CONTEXT_ID + -c LIFESPAN_COUNT +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $contextId = $input->getArgument('context-id'); + $lifespan = $input->getOption('lifespan-count'); + context_create($projectId, $contextId, $sessionId, $lifespan); + }) +); + +// delete context command +$application->add((new Command('context-delete')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->addArgument('context-id', InputArgument::REQUIRED, 'ID of the context.') + ->setDescription('Delete context of provided context id.') + ->setHelp(<<%command.name% command deletes context of provided context id. + + php %command.full_name% PROJECT_ID -s SESSION_ID CONTEXT_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $contextId = $input->getArgument('context-id'); + context_delete($projectId, $contextId, $sessionId); + }) +); + +// list session entity type command +$application->add((new Command('session-entity-type-list')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->setDescription('List session entity types.') + ->setHelp(<<%command.name% command lists session entity types. + + php %command.full_name% PROJECT_ID -s SESSION_ID +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + session_entity_type_list($projectId, $sessionId); + }) +); + +// create session entity type command +$application->add((new Command('session-entity-type-create')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->addArgument('entity-type-display-name', InputArgument::REQUIRED, + 'Display name of the entity type.') + ->addArgument('entity-values', InputArgument::IS_ARRAY | + InputArgument::REQUIRED, 'Entity values of the session entity type.') + ->addOption('entity-override-mode', 'o', InputOption::VALUE_REQUIRED, + 'ENTITY_OVERRIDE_MODE_OVERRIDE (default) or ENTITY_OVERRIDE_MODE_SUPPLEMENT', + SessionEntityType_EntityOverrideMode::ENTITY_OVERRIDE_MODE_OVERRIDE) + ->setDescription('Create session entity type.') + ->setHelp(<<%command.name% command creates session entity type with +display name and values provided. + + php %command.full_name% PROJECT_ID -s SESSION_ID + ENTITY_TYPE_DISPLAY_NAME entity_value [entity_values ...] + -o ENTITY_OVERRIDE_MODE +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $displayName = $input->getArgument('entity-type-display-name'); + $values = $input->getArgument('entity-values'); + $overrideMode = $input->getOption('entity-override-mode'); + session_entity_type_create($projectId, $displayName, $values, + $sessionId, $overrideMode); + }) +); + +// delete session entity type command +$application->add((new Command('session-entity-type-delete')) + ->addArgument('project-id', InputArgument::REQUIRED, + 'Project/agent id. Required.') + ->addOption('session-id', 's', InputOption::VALUE_REQUIRED, + 'Identifier of the DetectIntent session.') + ->addArgument('entity-type-display-name', InputArgument::REQUIRED, + 'Display name of the entity type.') + ->setDescription('Delete session entity type of provided display name.') + ->setHelp(<<%command.name% command deletes specified session entity type. + + php %command.full_name% PROJECT_ID SESSION_ID + ENTITY_TYPE_DISPLAY_NAME +EOF + ) + ->setCode(function ($input, $output) { + $projectId = $input->getArgument('project-id'); + $sessionId = $input->getOption('session-id'); + $displayName = $input->getArgument('entity-type-display-name'); + session_entity_type_delete($projectId, $displayName, $sessionId); + }) +); + +if (getenv('PHPUNIT_TESTS') === '1') { + return $application; +} +$application->run(); diff --git a/dialogflow/phpunit.xml.dist b/dialogflow/phpunit.xml.dist new file mode 100644 index 0000000000..6f073c4a76 --- /dev/null +++ b/dialogflow/phpunit.xml.dist @@ -0,0 +1,34 @@ + + + + + + test + + + + + + + + ./src + + + + + + diff --git a/dialogflow/resources/230pm.wav b/dialogflow/resources/230pm.wav new file mode 100644 index 0000000000..7509eca784 Binary files /dev/null and b/dialogflow/resources/230pm.wav differ diff --git a/dialogflow/resources/RoomReservation.zip b/dialogflow/resources/RoomReservation.zip new file mode 100644 index 0000000000..7873fb628c Binary files /dev/null and b/dialogflow/resources/RoomReservation.zip differ diff --git a/dialogflow/resources/book_a_room.wav b/dialogflow/resources/book_a_room.wav new file mode 100644 index 0000000000..9124e92794 Binary files /dev/null and b/dialogflow/resources/book_a_room.wav differ diff --git a/dialogflow/resources/half_an_hour.wav b/dialogflow/resources/half_an_hour.wav new file mode 100644 index 0000000000..71010a871b Binary files /dev/null and b/dialogflow/resources/half_an_hour.wav differ diff --git a/dialogflow/resources/mountain_view.wav b/dialogflow/resources/mountain_view.wav new file mode 100644 index 0000000000..1c5437f7cb Binary files /dev/null and b/dialogflow/resources/mountain_view.wav differ diff --git a/dialogflow/resources/today.wav b/dialogflow/resources/today.wav new file mode 100644 index 0000000000..d47ed78b35 Binary files /dev/null and b/dialogflow/resources/today.wav differ diff --git a/dialogflow/resources/two_people.wav b/dialogflow/resources/two_people.wav new file mode 100644 index 0000000000..5114ebbd31 Binary files /dev/null and b/dialogflow/resources/two_people.wav differ diff --git a/dialogflow/src/context_create.php b/dialogflow/src/context_create.php new file mode 100644 index 0000000000..9ea0292e96 --- /dev/null +++ b/dialogflow/src/context_create.php @@ -0,0 +1,41 @@ +sessionName($projectId, $sessionId); + $contextName = $contextsClient->contextName($projectId, $sessionId, $contextId); + $context = new Context(); + $context->setName($contextName); + $context->setLifespanCount($lifespan); + + // create context + $response = $contextsClient->createContext($parent, $context); + printf('Context created: %s' . PHP_EOL, $response->getName()); + + $contextsClient->close(); +} +// [END dialogflow_create_context] diff --git a/dialogflow/src/context_delete.php b/dialogflow/src/context_delete.php new file mode 100644 index 0000000000..fc583bdb76 --- /dev/null +++ b/dialogflow/src/context_delete.php @@ -0,0 +1,34 @@ +contextName($projectId, $sessionId, + $contextId); + $contextsClient->deleteContext($contextName); + printf('Context deleted: %s' . PHP_EOL, $contextName); + + $contextsClient->close(); +} +// [END dialogflow_delete_context] diff --git a/dialogflow/src/context_list.php b/dialogflow/src/context_list.php new file mode 100644 index 0000000000..9980eba0fd --- /dev/null +++ b/dialogflow/src/context_list.php @@ -0,0 +1,39 @@ +sessionName($projectId, $sessionId); + $contexts = $contextsClient->listContexts($parent); + + printf('Contexts for session %s' . PHP_EOL, $parent); + foreach ($contexts->iterateAllElements() as $context) { + // print relevant info + printf('Context name: %s' . PHP_EOL, $context->getName()); + printf('Lifespan count: %d' . PHP_EOL, $context->getLifespanCount()); + } + + $contextsClient->close(); +} +// [END dialogflow_list_context] diff --git a/dialogflow/src/detect_intent_audio.php b/dialogflow/src/detect_intent_audio.php new file mode 100644 index 0000000000..9c7aa341f9 --- /dev/null +++ b/dialogflow/src/detect_intent_audio.php @@ -0,0 +1,70 @@ +sessionName($projectId, $sessionId ?: uniqid()); + printf('Session path: %s' . PHP_EOL, $session); + + // load audio file + $inputAudio = file_get_contents($path); + + // hard coding audio_encoding and sample_rate_hertz for simplicity + $audioConfig = new InputAudioConfig(); + $audioConfig->setAudioEncoding(AudioEncoding::AUDIO_ENCODING_LINEAR_16); + $audioConfig->setLanguageCode($languageCode); + $audioConfig->setSampleRateHertz(16000); + + // create query input + $queryInput = new QueryInput(); + $queryInput->setAudioConfig($audioConfig); + + // get response and relevant info + $response = $sessionsClient->detectIntent($session, $queryInput, ['inputAudio' => $inputAudio]); + $queryResult = $response->getQueryResult(); + $queryText = $queryResult->getQueryText(); + $intent = $queryResult->getIntent(); + $displayName = $intent->getDisplayName(); + $confidence = $queryResult->getIntentDetectionConfidence(); + $fulfilmentText = $queryResult->getFulfillmentText(); + + // output relevant info + print(str_repeat("=", 20) . PHP_EOL); + printf('Query text: %s' . PHP_EOL, $queryText); + printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, + $confidence); + print(PHP_EOL); + printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); + + $sessionsClient->close(); +} +// [END dialogflow_detect_intent_audio] diff --git a/dialogflow/src/detect_intent_stream.php b/dialogflow/src/detect_intent_stream.php new file mode 100644 index 0000000000..7ebe8862b5 --- /dev/null +++ b/dialogflow/src/detect_intent_stream.php @@ -0,0 +1,107 @@ +sessionName($projectId, $sessionId ?: uniqid()); + printf('Session path: %s' . PHP_EOL, $session); + + // hard coding audio_encoding and sample_rate_hertz for simplicity + $audioConfig = new InputAudioConfig(); + $audioConfig->setAudioEncoding(AudioEncoding::AUDIO_ENCODING_LINEAR_16); + $audioConfig->setLanguageCode($languageCode); + $audioConfig->setSampleRateHertz(16000); + + // create query input + $queryInput = new QueryInput(); + $queryInput->setAudioConfig($audioConfig); + + // first request contains the configuration + $request = new StreamingDetectIntentRequest(); + $request->setSession($session); + $request->setQueryInput($queryInput); + $requests = [$request]; + + // we are going to read small chunks of audio data from + // a local audio file. in practice, these chunks should + // come from an audio input device. + $audioStream = fopen($path, 'rb'); + while (true) { + $chunk = stream_get_contents($audioStream, 4096); + if (!$chunk) { + break; + } + $request = new StreamingDetectIntentRequest(); + $request->setInputAudio($chunk); + $requests[] = $request; + } + + // intermediate transcript info + print(PHP_EOL . str_repeat("=", 20) . PHP_EOL); + $stream = $sessionsClient->streamingDetectIntent(); + foreach ($requests as $request) { + $stream->write($request); + } + foreach ($stream->closeWriteAndReadAll() as $response) { + $recognitionResult = $response->getRecognitionResult(); + if ($recognitionResult) { + $transcript = $recognitionResult->getTranscript(); + printf('Intermediate transcript: %s' . PHP_EOL, $transcript); + } + } + print(str_repeat("=", 20) . PHP_EOL); + + // get final response and relevant info + $queryResult = $response->getQueryResult(); + $queryText = $queryResult->getQueryText(); + $intent = $queryResult->getIntent(); + $displayName = $intent->getDisplayName(); + $confidence = $queryResult->getIntentDetectionConfidence(); + $fulfilmentText = $queryResult->getFulfillmentText(); + + // output relevant info + printf('Query text: %s' . PHP_EOL, $queryText); + printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, + $confidence); + print(PHP_EOL); + printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); + + $sessionsClient->close(); +} +// [END dialogflow_detect_intent_stream] diff --git a/dialogflow/src/detect_intent_texts.php b/dialogflow/src/detect_intent_texts.php new file mode 100644 index 0000000000..b9a071d7a0 --- /dev/null +++ b/dialogflow/src/detect_intent_texts.php @@ -0,0 +1,68 @@ +sessionName($projectId, $sessionId ?: uniqid()); + printf('Session path: %s' . PHP_EOL, $session); + + // query for each string in array + foreach ($texts as $text) { + // create text input + $textInput = new TextInput(); + $textInput->setText($text); + $textInput->setLanguageCode($languageCode); + + // create query input + $queryInput = new QueryInput(); + $queryInput->setText($textInput); + + // get response and relevant info + $response = $sessionsClient->detectIntent($session, $queryInput); + $queryResult = $response->getQueryResult(); + $queryText = $queryResult->getQueryText(); + $intent = $queryResult->getIntent(); + $displayName = $intent->getDisplayName(); + $confidence = $queryResult->getIntentDetectionConfidence(); + $fulfilmentText = $queryResult->getFulfillmentText(); + + // output relevant info + print(str_repeat("=", 20) . PHP_EOL); + printf('Query text: %s' . PHP_EOL, $queryText); + printf('Detected intent: %s (confidence: %f)' . PHP_EOL, $displayName, + $confidence); + print(PHP_EOL); + printf('Fulfilment text: %s' . PHP_EOL, $fulfilmentText); + } + + $sessionsClient->close(); +} +// [END dialogflow_detect_intent_text] diff --git a/dialogflow/src/entity_create.php b/dialogflow/src/entity_create.php new file mode 100644 index 0000000000..57e70dad88 --- /dev/null +++ b/dialogflow/src/entity_create.php @@ -0,0 +1,50 @@ +entityTypeName($projectId, + $entityTypeId); + + // prepare entity + $entity = new EntityType_Entity(); + $entity->setValue($entityValue); + $entity->setSynonyms($synonyms); + + // create entity + $response = $entityTypesClient->batchCreateEntities($parent, [$entity]); + printf('Entity created: %s' . PHP_EOL, $response->getName()); + + $entityTypesClient->close(); +} +// [END dialogflow_create_entity] diff --git a/dialogflow/src/entity_delete.php b/dialogflow/src/entity_delete.php new file mode 100644 index 0000000000..a5308034b5 --- /dev/null +++ b/dialogflow/src/entity_delete.php @@ -0,0 +1,37 @@ +entityTypeName($projectId, + $entityTypeId); + $entityTypesClient->batchDeleteEntities($parent, [$entityValue]); + printf('Entity deleted: %s' . PHP_EOL, $entityValue); + + $entityTypesClient->close(); +} +// [END dialogflow_delete_entity] diff --git a/dialogflow/src/entity_list.php b/dialogflow/src/entity_list.php new file mode 100644 index 0000000000..a0acf6a775 --- /dev/null +++ b/dialogflow/src/entity_list.php @@ -0,0 +1,46 @@ +entityTypeName($projectId, + $entityTypeId); + $entityType = $entityTypesClient->getEntityType($parent); + + // get entities + $entities = $entityType->getEntities(); + foreach ($entities as $entity) { + print(PHP_EOL); + printf('Entity value: %s' . PHP_EOL, $entity->getValue()); + print('Synonyms: '); + foreach ($entity->getSynonyms() as $synonym) { + print($synonym . "\t"); + } + print(PHP_EOL); + } + + $entityTypesClient->close(); +} +// [END dialogflow_list_entity] diff --git a/dialogflow/src/entity_type_create.php b/dialogflow/src/entity_type_create.php new file mode 100644 index 0000000000..86dd64dd28 --- /dev/null +++ b/dialogflow/src/entity_type_create.php @@ -0,0 +1,44 @@ +projectAgentName($projectId); + $entityType = new EntityType(); + $entityType->setDisplayName($displayName); + $entityType->setKind($kind); + + // create entity type + $response = $entityTypesClient->createEntityType($parent, $entityType); + printf('Entity type created: %s' . PHP_EOL, $response->getName()); + + $entityTypesClient->close(); +} +// [END dialogflow_create_entity_type] diff --git a/dialogflow/src/entity_type_delete.php b/dialogflow/src/entity_type_delete.php new file mode 100644 index 0000000000..334da12c07 --- /dev/null +++ b/dialogflow/src/entity_type_delete.php @@ -0,0 +1,37 @@ +entityTypeName($projectId, + $entityTypeId); + $entityTypesClient->deleteEntityType($parent); + printf('Entity type deleted: %s' . PHP_EOL, $parent); + + $entityTypesClient->close(); +} +// [END dialogflow_delete_entity_type] diff --git a/dialogflow/src/entity_type_list.php b/dialogflow/src/entity_type_list.php new file mode 100644 index 0000000000..e256c6b822 --- /dev/null +++ b/dialogflow/src/entity_type_list.php @@ -0,0 +1,39 @@ +projectAgentName($projectId); + $entityTypes = $entityTypesClient->listEntityTypes($parent); + + foreach ($entityTypes->iterateAllElements() as $entityType) { + // print relevant info + printf('Entity type name: %s' . PHP_EOL, $entityType->getName()); + printf('Entity type display name: %s' . PHP_EOL, $entityType->getDisplayName()); + printf('Number of entities: %d' . PHP_EOL, count($entityType->getEntities())); + } + + $entityTypesClient->close(); +} +// [END dialogflow_list_entity_type] diff --git a/dialogflow/src/intent_create.php b/dialogflow/src/intent_create.php new file mode 100644 index 0000000000..1a34474d08 --- /dev/null +++ b/dialogflow/src/intent_create.php @@ -0,0 +1,69 @@ +projectAgentName($projectId); + + // prepare training phrases for intent + $trainingPhrases = []; + foreach ($trainingPhraseParts as $trainingPhrasePart) { + $part = new Intent_TrainingPhrase_Part; + $part->setText($trainingPhrasePart); + + // create new training phrase for each provided part + $trainingPhrase = new Intent_TrainingPhrase(); + $trainingPhrase->setParts([$part]); + $trainingPhrases[] = $trainingPhrase; + } + + // prepare messages for intent + $text = new Intent_Message_Text(); + $text->setText($messageTexts); + $message = new Intent_Message(); + $message->setText($text); + + // prepare intent + $intent = new Intent(); + $intent->setDisplayName($displayName); + $intent->setTrainingPhrases($trainingPhrases); + $intent->setMessages([$message]); + + // create intent + $response = $intentsClient->createIntent($parent, $intent); + printf('Intent created: %s' . PHP_EOL, $response->getName()); + + $intentsClient->close(); +} +// [END dialogflow_create_intent] diff --git a/dialogflow/src/intent_delete.php b/dialogflow/src/intent_delete.php new file mode 100644 index 0000000000..fc9a62a419 --- /dev/null +++ b/dialogflow/src/intent_delete.php @@ -0,0 +1,36 @@ +intentName($projectId, $intentId); + + $intentsClient->deleteIntent($intentName); + printf('Intent deleted: %s' . PHP_EOL, $intentName); + + $intentsClient->close(); +} +// [END dialogflow_delete_intent] diff --git a/dialogflow/src/intent_list.php b/dialogflow/src/intent_list.php new file mode 100644 index 0000000000..d65617eac2 --- /dev/null +++ b/dialogflow/src/intent_list.php @@ -0,0 +1,54 @@ +projectAgentName($projectId); + $intents = $intentsClient->listIntents($parent); + + foreach ($intents->iterateAllElements() as $intent) { + // print relevant info + print(str_repeat("=", 20) . PHP_EOL); + printf('Intent name: %s' . PHP_EOL, $intent->getName()); + printf('Intent display name: %s' . PHP_EOL, $intent->getDisplayName()); + printf('Action: %s' . PHP_EOL, $intent->getAction()); + printf('Root followup intent: %s' . PHP_EOL, + $intent->getRootFollowupIntentName()); + printf('Parent followup intent: %s' . PHP_EOL, + $intent->getParentFollowupIntentName()); + print(PHP_EOL); + + print('Input contexts: ' . PHP_EOL); + foreach ($intent->getInputContextNames() as $inputContextName) { + printf("\t Name: %s" . PHP_EOL, $inputContextName); + } + + print('Output contexts: ' . PHP_EOL); + foreach ($intent->getOutputContexts() as $outputContext) { + printf("\t Name: %s" . PHP_EOL, $outputContext->getName()); + } + } + $intentsClient->close(); +} +// [END dialogflow_list_intent] diff --git a/dialogflow/src/session_entity_type_create.php b/dialogflow/src/session_entity_type_create.php new file mode 100644 index 0000000000..bd1e8c58f8 --- /dev/null +++ b/dialogflow/src/session_entity_type_create.php @@ -0,0 +1,61 @@ +sessionName($projectId, $sessionId); + + // prepare name + $sessionEntityTypeName = $sessionEntityTypesClient + ->sessionEntityTypeName($projectId, $sessionId, $displayName); + + // prepare entities + $entities = []; + foreach ($values as $value) { + $entity = new EntityType_Entity(); + $entity->setValue($value); + $entity->setSynonyms([$value]); + $entities[] = $entity; + } + + // prepare session entity type + $sessionEntityType = new SessionEntityType(); + $sessionEntityType->setName($sessionEntityTypeName); + $sessionEntityType->setEntityOverrideMode($overrideMode); + $sessionEntityType->setEntities($entities); + + // create session entity type + $response = $sessionEntityTypesClient->createSessionEntityType($parent, + $sessionEntityType); + printf('Session entity type created: %s' . PHP_EOL, $response->getName()); + + $sessionEntityTypesClient->close(); +} +// [END dialogflow_create_session_entity_type] diff --git a/dialogflow/src/session_entity_type_delete.php b/dialogflow/src/session_entity_type_delete.php new file mode 100644 index 0000000000..43eb5612aa --- /dev/null +++ b/dialogflow/src/session_entity_type_delete.php @@ -0,0 +1,37 @@ +sessionEntityTypeName($projectId, $sessionId, $displayName); + $sessionEntityTypesClient->deleteSessionEntityType($sessionEntityTypeName); + printf('Session entity type deleted: %s' . PHP_EOL, $sessionEntityTypeName); + + $sessionEntityTypesClient->close(); +} +// [END dialogflow_delete_session_entity_type] diff --git a/dialogflow/src/session_entity_type_list.php b/dialogflow/src/session_entity_type_list.php new file mode 100644 index 0000000000..64244af75f --- /dev/null +++ b/dialogflow/src/session_entity_type_list.php @@ -0,0 +1,35 @@ +sessionName($projectId, $sessionId); + $sessionEntityTypes = $sessionEntityTypesClient->listSessionEntityTypes($parent); + print('Session entity types:' . PHP_EOL); + foreach ($sessionEntityTypes->iterateAllElements() as $sessionEntityType) { + printf('Session entity type name: %s' . PHP_EOL, $sessionEntityType->getName()); + printf('Number of entities: %d' . PHP_EOL, count($sessionEntityType->getEntities())); + } + $sessionEntityTypesClient->close(); +} +// [END dialogflow_list_session_entity_type] diff --git a/dialogflow/test/contextTest.php b/dialogflow/test/contextTest.php new file mode 100644 index 0000000000..65eb683e76 --- /dev/null +++ b/dialogflow/test/contextTest.php @@ -0,0 +1,85 @@ +sessionId = 'fake_session_for_testing'; + $this->contextId = 'fake_context_for_testing'; + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + } + + public function testCreateContext() + { + $this->runCommand('context-create', [ + 'context-id' => $this->contextId + ]); + $output = $this->runCommand('context-list'); + + $this->assertContains($this->contextId, $output); + } + + /** @depends testCreateContext */ + public function testDeleteContext() + { + $this->runCommand('context-delete', [ + 'context-id' => $this->contextId + ]); + $output = $this->runCommand('context-list'); + + $this->assertNotContains($this->contextId, $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId, + '--session-id' => $this->sessionId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +} diff --git a/dialogflow/test/detectIntentTest.php b/dialogflow/test/detectIntentTest.php new file mode 100644 index 0000000000..ad6f0894f0 --- /dev/null +++ b/dialogflow/test/detectIntentTest.php @@ -0,0 +1,93 @@ +texts = array('hello', 'book a meeting room', 'mountain view'); + $this->audioFilePath = realpath(__DIR__ . '/../resources/book_a_room.wav'); + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + } + + public function testDetectText() + { + $output = $this->runCommand('detect-intent-texts', [ + 'texts' => $this->texts + ]); + + $this->assertContains('date', $output); + } + + public function testDetectAudio() + { + $output = $this->runCommand('detect-intent-audio', [ + 'path' => $this->audioFilePath + ]); + + $this->assertContains('would you like to reserve a room', $output); + } + + public function testDetectStream() + { + if (!extension_loaded('grpc')) { + $this->markTestSkipped('Must enable grpc extension.'); + } + $output = $this->runCommand('detect-intent-stream', [ + 'path' => $this->audioFilePath + ]); + + $this->assertContains('would you like to reserve a room', $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +} diff --git a/dialogflow/test/entityTest.php b/dialogflow/test/entityTest.php new file mode 100644 index 0000000000..90918e32bc --- /dev/null +++ b/dialogflow/test/entityTest.php @@ -0,0 +1,101 @@ +entityTypeId = 'e57238e2-e692-44ea-9216-6be1b2332e2a'; + $this->entityValue1 = 'fake_entit_for_testing_1'; + $this->entityValue2 = 'fake_entit_for_testing_2'; + $this->synonyms = array('fake_synonym_for_testing_1', 'fake_synonym_for_testing_2'); + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + } + + public function testCreateEntity() + { + $this->runCommand('entity-create', [ + 'entity-value' => $this->entityValue1 + ]); + $this->runCommand('entity-create', [ + 'entity-value' => $this->entityValue2, + 'synonyms' => $this->synonyms + ]); + $output = $this->runCommand('entity-list'); + + $this->assertContains($this->entityValue1, $output); + $this->assertContains($this->entityValue2, $output); + foreach ($this->synonyms as $synonym) { + $this->assertContains($synonym, $output); + } + } + + /** @depends testCreateEntity */ + public function testDeleteEntity() + { + $this->runCommand('entity-delete', [ + 'entity-value' => $this->entityValue1 + ]); + $this->runCommand('entity-delete', [ + 'entity-value' => $this->entityValue2 + ]); + $output = $this->runCommand('entity-list'); + + $this->assertNotContains($this->entityValue1, $output); + $this->assertNotContains($this->entityValue2, $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId, + 'entity-type-id' => $this->entityTypeId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +} diff --git a/dialogflow/test/entityTypeTest.php b/dialogflow/test/entityTypeTest.php new file mode 100644 index 0000000000..cf94be4c11 --- /dev/null +++ b/dialogflow/test/entityTypeTest.php @@ -0,0 +1,87 @@ +entityTypeDisplayName = 'fake_display_name_for_testing'; + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + } + + public function testCreateEntityType() + { + $response = $this->runCommand('entity-type-create', [ + 'display-name' => $this->entityTypeDisplayName + ]); + $output = $this->runCommand('entity-type-list'); + + $this->assertContains($this->entityTypeDisplayName, $output); + + $response = str_replace(array("\r", "\n"), '', $response); + $response = explode('/', $response); + $entityTypeId = end($response); + return $entityTypeId; + } + + /** @depends testCreateEntityType */ + public function testDeleteEntityType($entityTypeId) + { + $this->runCommand('entity-type-delete', [ + 'entity-type-id' => $entityTypeId + ]); + $output = $this->runCommand('entity-type-list'); + + $this->assertNotContains($this->entityTypeDisplayName, $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +} diff --git a/dialogflow/test/intentTest.php b/dialogflow/test/intentTest.php new file mode 100644 index 0000000000..e3555926d2 --- /dev/null +++ b/dialogflow/test/intentTest.php @@ -0,0 +1,93 @@ +displayName = 'fake_display_name_for_testing'; + $this->messageTexts = array('fake_message_for_testing_1', 'fake_message_for_testing_2'); + $this->trainingPhraseParts = array('fake_phrase_1', 'fake_phrase_2'); + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + } + + public function testCreateIntent() + { + $response = $this->runCommand('intent-create', [ + 'display-name' => $this->displayName, + '--training-phrases-parts' => $this->trainingPhraseParts, + '--message-texts' => $this->messageTexts + ]); + $output = $this->runCommand('intent-list'); + + $this->assertContains($this->displayName, $output); + + $response = str_replace(array("\r", "\n"), '', $response); + $response = explode('/', $response); + $intentId = end($response); + return $intentId; + } + + /** @depends testCreateIntent */ + public function testDeleteIntent($intentId) + { + $this->runCommand('intent-delete', [ + 'intent-id' => $intentId + ]); + $output = $this->runCommand('intent-list'); + + $this->assertNotContains($this->displayName, $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +} diff --git a/dialogflow/test/sessionEntityTypeTest.php b/dialogflow/test/sessionEntityTypeTest.php new file mode 100644 index 0000000000..c6abb9be03 --- /dev/null +++ b/dialogflow/test/sessionEntityTypeTest.php @@ -0,0 +1,116 @@ +entityTypeDisplayName = 'fake_display_name_for_testing'; + $this->entityValues = array('fake_entity_value_1', 'fake_entity_value_2'); + $this->sessionId = 'fake_session_for_testing'; + + if (!$projectId = getenv('GOOGLE_PROJECT_ID')) { + return $this->markTestSkipped('Set the GOOGLE_PROJECT_ID ' . + 'environment variable'); + } + $this->projectId = $projectId; + + if (!$creds = getenv('GOOGLE_APPLICATION_CREDENTIALS')) { + $this->markTestSkipped('Set the GOOGLE_APPLICATION_CREDENTIALS ' . + 'environment variable'); + } + + $application = require __DIR__ . '/../dialogflow.php'; + $setUpCommand = $application->get('entity-type-create'); + $createCommand = $application->get('session-entity-type-create'); + $listCommand = $application->get('session-entity-type-list'); + $deleteCommand = $application->get('session-entity-type-delete'); + $cleanUpCommand = $application->get('entity-type-delete'); + $this->commandTesterSetUp = new CommandTester($setUpCommand); + $this->commandTesterCreate = new CommandTester($createCommand); + $this->commandTesterList = new CommandTester($listCommand); + $this->commandTesterDelete = new CommandTester($deleteCommand); + $this->commandTesterCleanUp = new CommandTester($cleanUpCommand); + } + + public function testCreateSessionEntityType() + { + $response = $this->runCommand('entity-type-create',[ + 'display-name' => $this->entityTypeDisplayName + ]); + $this->runCommand('session-entity-type-create', [ + 'entity-type-display-name' => $this->entityTypeDisplayName, + 'entity-values' => $this->entityValues, + '--session-id' => $this->sessionId + ]); + $output = $this->runCommand('session-entity-type-list', [ + '--session-id' => $this->sessionId + ]); + + $this->assertContains($this->entityTypeDisplayName, $output); + + $response = str_replace(array("\r", "\n"), '', $response); + $response = explode('/', $response); + $entityTypeId = end($response); + return $entityTypeId; + } + + /** @depends testCreateSessionEntityType */ + public function testDeleteSessionEntityType($entityTypeId) + { + $this->runCommand('session-entity-type-delete', [ + 'entity-type-display-name' => $this->entityTypeDisplayName, + '--session-id' => $this->sessionId + ]); + $output = $this->runCommand('session-entity-type-list', [ + '--session-id' => $this->sessionId + ]); + $this->runCommand('entity-type-delete', [ + 'entity-type-id' => $entityTypeId + ]); + + $this->assertNotContains($this->entityTypeDisplayName, $output); + } + + private function runCommand($commandName, $args=[]) + { + $application = require __DIR__ . '/../dialogflow.php'; + $command = $application->get($commandName); + $commandTester = new CommandTester($command); + ob_start(); + $commandTester->execute( + $args + [ + 'project-id' => $this->projectId + ], + ['interactive' => false] + ); + return ob_get_clean(); + } +}