質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

composer

Composerとは、PHP5.3.2以上で使用可能なパッケージ管理ツールです。指定ディレクトリ内だけでパッケージ管理します。

Q&A

解決済

2回答

9512閲覧

google-api-php-clientがインストールできません。

退会済みユーザー

退会済みユーザー

総合スコア0

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

composer

Composerとは、PHP5.3.2以上で使用可能なパッケージ管理ツールです。指定ディレクトリ内だけでパッケージ管理します。

0グッド

0クリップ

投稿2018/11/01 08:12

編集2018/11/01 09:30

google-api-php-clientのgithubのcomposer.jsonをコピペして、コマンドプロンプトでcomposer require google/apiclient:"^2.0"を実行したのですが、以下のエラーが出ました。
どうすればインストールできますか?

C:\Users\UserName>composer require google/apiclient:"^2.0" ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package google/apiclient No version set (parsed as 1.0.0) is satisfiable by google/apiclient[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability. Installation failed, reverting ./composer.json to its original content.

環境
windows10 64bit
Composer version: 1.7.2
PHP version: 7.2.10

追記
composer updateを実行したら以下のようになりました。

Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 41 installs, 0 updates, 1 removal - Removing abraham/twitteroauth (0.9.2) - Installing symfony/polyfill-ctype (v1.10.0): Downloading (100%) - Installing symfony/yaml (v3.4.17): Downloading (100%) - Installing sebastian/version (1.0.6): Downloading (100%) - Installing sebastian/global-state (1.1.1): Downloading (100%) - Installing sebastian/recursion-context (1.0.5): Downloading (100%) - Installing sebastian/exporter (1.2.2): Downloading (100%) - Installing sebastian/environment (1.3.8): Downloading (100%) - Installing sebastian/diff (1.4.3): Downloading (100%) - Installing sebastian/comparator (1.2.4): Downloading (100%) - Installing doctrine/instantiator (1.1.0): Downloading (100%) - Installing phpunit/php-text-template (1.2.1): Downloading (100%) - Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%) - Installing phpunit/php-timer (1.0.9): Downloading (100%) - Installing phpunit/php-file-iterator (1.4.5): Downloading (100%) - Installing phpunit/php-token-stream (1.4.12): Downloading (100%) - Installing phpunit/php-code-coverage (2.2.4): Downloading (100%) - Installing webmozart/assert (1.3.0): Downloading (100%) - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%) - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%) - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%) - Installing phpspec/prophecy (1.8.0): Downloading (100%) - Installing phpunit/phpunit (4.8.36): Downloading (100%) - Installing psr/cache (1.0.1): Downloading (100%) - Installing psr/http-message (1.0.1): Downloading (100%) - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%) - Installing guzzlehttp/promises (v1.3.1): Downloading (100%) - Installing guzzlehttp/guzzle (6.3.3): Downloading (100%) - Installing firebase/php-jwt (v5.0.0): Downloading (100%) - Installing google/auth (v1.4.0): Downloading (100%) - Installing google/apiclient-services (v0.74): Downloading (100%) - Installing psr/log (1.0.2): Downloading (100%) - Installing monolog/monolog (1.23.0): Downloading (100%) - Installing phpseclib/phpseclib (2.0.11): Downloading (100%) - Installing squizlabs/php_codesniffer (2.9.1): Downloading (100%) - Installing symfony/polyfill-mbstring (v1.10.0): Downloading (100%) - Installing symfony/dom-crawler (v2.8.46): Downloading (100%) - Installing symfony/css-selector (v2.8.46): Downloading (100%) - Installing league/flysystem (1.0.46): Downloading (100%) - Installing cache/taggable-cache (0.4.3): Downloading (100%) - Installing cache/adapter-common (0.3.3): Downloading (100%) - Installing cache/filesystem-adapter (0.3.3): Downloading (100%) symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command) sebastian/global-state suggests installing ext-uopz (*) phpunit/phpunit-mock-objects suggests installing ext-soap (*) phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1) phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver) monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib) monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome) monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar) monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server) monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server) phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.) phpseclib/phpseclib suggests installing ext-mcrypt (Install the Mcrypt extension in order to speed up a few other cryptographic operations.) phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.) league/flysystem suggests installing ext-fileinfo (Required for MimeType) league/flysystem suggests installing ext-ftp (Allows you to use FTP server storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) Writing lock file Generating autoload files [RuntimeException] Could not scan for classes inside "src/Google/Service/" which does not appe ar to be a file nor a folder update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

追記2
上記の処理でできたvendorにgithubからダウンロードしたgoogle-api-php-clientを入れて以下のコードを実行しました。

php

1<?php 2require_once("/vendor/autoload.php"); 3session_start(); 4 5$OAUTH2_CLIENT_ID = ""; 6$OAUTH2_CLIENT_SECRET = ""; 7 8$client = new Google_Client(); 9$client->setClientId($OAUTH2_CLIENT_ID); 10$client->setClientSecret($OAUTH2_CLIENT_SECRET); 11?>

そうしたら以下のエラーが出ました。

Fatal error: Uncaught Error: Class 'Google_Client' not found in C:\xampp\htdocs\TestPHP\test.php:8 Stack trace: #0 {main} thrown in C:\test.php on line 8

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2018/11/01 08:38

当該エラー自体はcomposerでよく見るもののように思いますが、調べて試しても解決しませんでしたか?
退会済みユーザー

退会済みユーザー

2018/11/01 08:57

解決しませんでした。
m.ts10806

2018/11/01 08:58

どのように調べたか提示してください。調べ方が良くないとか試し方が良くないとかよくあることです。何をしたか提示しないと、質問者さんが試したようなことが回答につく可能性が高いです。そうなるとどちらも無駄足になりますので。
guest

回答2

0

google-api-php-clientのgithubのcomposer.jsonをコピペして、コマンドプロンプトでcomposer require google/apiclient:"^2.0"を実行したのですが、以下のエラーが出ました。

これはどういう経緯・意図で「 google-api-php-clientのgithubのcomposer.jsonをコピペして、コマンドプロンプトでcomposer require google/apiclient:"^2.0"を実行」された感じでしょう?

google/apiclientcomposer.json をコピペせずシンプルに composer require google/apiclient:"^2.0" を実行すると、既存の依存関係との衝突が無いかぎりインストールが成功しそうな感じがしますが、 google/apiclientcomposer.json をコピペするのにはどのような理由がありますか?それによって解決策が異なるような気がします。

(私は試していませんが)パッと見の印象としては google/apiclientcomposer.json があるディレクトリで composer requiregoogle/apiclient を追加しようとすると衝突してそのエラーが出てしまう可能性は高いように思います。

投稿2018/11/01 13:13

gh640

総合スコア1407

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

gh640

2018/11/01 13:14

入れ違いでした。。ご解決されたとのことでよかったです。
guest

0

ベストアンサー

githubからgoogle-api-php-clientをダウンロードして、その中でcomposer updateを実行したらインストールできました。

投稿2018/11/01 13:07

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問