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

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

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

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

解決済

1回答

1656閲覧

laravel excelを導入したい。

ETO3

総合スコア45

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

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

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/09/08 07:27

編集2021/09/08 11:24

環境: windows,laravel8,docker,php7.3

環境構築に手間取っています。

#やりたいこと
phpの拡張機能gdをインストールして有効にしたい。

#やったこと

使用しているPCはwindows10で、新規で作成したlaravelプロジェクトをdcokerにビルドしました。
laravel excel ライブラリを使用したく、dockerコンテナ内で以下のコマンドを実行しました。

composer require maatwebsite/excel

しかし以下のエラーが出ました。

root@xxxxxxxxxxx:/var/www/laravel# composer require maatwebsite/excel PHP Warning: PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/gd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/ Using version ^3.1 for maatwebsite/excel ./composer.json has been updated Loading composer repositories with package information Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/ Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - maatwebsite/excel 3.1.28 requires phpoffice/phpspreadsheet 1.16.* -> satisfiable by phpoffice/phpspreadsheet[1.16.0]. - maatwebsite/excel 3.1.29 requires phpoffice/phpspreadsheet 1.16.* -> satisfiable by phpoffice/phpspreadsheet[1.16.0]. - maatwebsite/excel 3.1.30 requires phpoffice/phpspreadsheet 1.16.* -> satisfiable by phpoffice/phpspreadsheet[1.16.0]. - maatwebsite/excel 3.1.33 requires phpoffice/phpspreadsheet ^1.18 -> satisfiable by phpoffice/phpspreadsheet[1.18.0]. - maatwebsite/excel 3.1.0 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0]. - maatwebsite/excel 3.1.1 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].                                ~中略~ - maatwebsite/excel 3.1.7 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0]. - maatwebsite/excel 3.1.8 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0]. - maatwebsite/excel 3.1.9 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.14.1, 1.15.0, 1.16.0, 1.17.0, 1.17.1, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0]. - maatwebsite/excel 3.1.x-dev requires phpoffice/phpspreadsheet ^1.18 -> satisfiable by phpoffice/phpspreadsheet[1.18.0]. - phpoffice/phpspreadsheet 1.9.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - phpoffice/phpspreadsheet 1.8.2 requires ext-gd * -> the requested PHP extension gd is missing from your system. - phpoffice/phpspreadsheet 1.8.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.                                ~中略~ - phpoffice/phpspreadsheet 1.10.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - phpoffice/phpspreadsheet 1.18.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - phpoffice/phpspreadsheet 1.18.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - Installation request for maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.14, 3.1.15, 3.1.16, 3.1.17, 3.1.18, 3.1.19, 3.1.2, 3.1.20, 3.1.21, 3.1.22, 3.1.23, 3.1.24, 3.1.25, 3.1.26, 3.1.27, 3.1.28, 3.1.29, 3.1.3, 3.1.30, 3.1.31, 3.1.32, 3.1.33, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.1.x-dev]. To enable extensions, verify that they are enabled in your .ini files: - /usr/local/etc/php/php.ini - /usr/local/etc/php/conf.d/docker-php-ext-intl.ini - /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini - /usr/local/etc/php/conf.d/docker-php-ext-zip.ini You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode. Installation failed, reverting ./composer.json to its original content.

エラーを見るgdという拡張機能が有効ではないためエラーが起きているように見えます。

php.iniでは

extension=gd

となっておりextensionのディレクトリを見てみるとgdがないのでgdをインストール?する必要があるのですが、
調べると以下のコマンドでインストールできることがわかりました。

yum -y install php-gd

しかし当方使用しているPCがwindowsでyumコマンドが使えません。
yumコマンドもwindowsに導入する手段が見あたらず手詰まっております。

どうすればgdの拡張機能を導入できますでしょうか?
ご教授願いたいです。よろしくおねがいします。

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

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

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

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

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

FKM

2021/09/08 07:53

yumはあくまでRedhat系linuxの外部インストール手段です。Windowsの場合は直接dllを引っ張ってくる必要がありますよ。
ETO3

2021/09/08 09:19 編集

コメントありがとうございます! 直接dllを引っ張ってくるというのは、どこか配布場所でダウンロードして直接extensionのディレクトリに配置するということでしょうか? 試しにローカルPCにあったphp_gd.dllというのを配置してcomposer require maatwebsite/excelを再度実行してみたのですが以下のようにinvalid ELF headerとでてエラーがでました… ``` PHP Warning: PHP Startup: Unable to load dynamic library 'php_gd.dll' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/php_gd.dll (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/php_gd.dll: invalid ELF header), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/php_gd.dll.so (/usr/local/lib/php/extensions/no-debug-non-zts-20180731/php_gd.dll.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 ``` 上記のだと互換性がないみたいなので有効なdllが欲しいのですが、どちらで入手できるかご教授頂きたいです。 すみません探してみたもののよくわらなくて…よろしくお願いします…
phper.k

2021/09/08 09:19

docker 使ってるんなら、docker の中で、コマンド実行する。 docker-compose.yml を書き換えてでインストールします。
ETO3

2021/09/09 07:20

ありがとうございます!おかげさまで解決できました!
guest

回答1

0

自己解決

頂いたコメントを元にdocker-compose.yml gdで調べたら色々と設定方法がでてきました。
ありがとうございました!

投稿2021/09/09 07:21

ETO3

総合スコア45

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問