前記事で作成した環境にCodeIgniter4をcomposerからインストールしていく。CodeIngniter4インストールに必要となったものまとめは一番下に書いていますので、結論だけ知りたい場合は途中読み飛ばしてください。
- (1回目)CodeIgniter4のインストールコマンド
- (エラー)Install or enable PHP’s curl extension / intl extension.
- (2回目)CodeIgniter4をインストール
- (エラー)The zip extension and unzip/7z commands are both missing, skipping.
- (3回目)CodeIgniter4をインストール
- (エラー)it is missing from your system. Install or enable PHP’s dom extension.
- (4回目)CodeIgniter4をインストール
- (エラー)require ext-mbstring * -> it is missing from your system. Install or enable PHP’s mbstring extension.
- (5回目)CodeIgniter4をインストール⇒成功
- 開発用Webサーバの起動(sparkコマンド)
- ★CodeIngniter4インストールに必要となったものまとめ
(1回目)CodeIgniter4のインストールコマンド
まずは下記コマンドを打ってみる。今回はtestappとする。
$ composer create-project codeigniter4/appstarter testapp
(エラー)Install or enable PHP’s curl extension / intl extension.
最初の実行結果。Composerを使ってパッケージをインストールするとき、不足パッケージがあれば以降のようにどんどんエラーが出てくる。ここでは何も知らないものとしてそのまま対応の経過をそのまま記載する。
Creating a "codeigniter4/appstarter" project at "./testapp"
Info from https://repo.packagist.org: #StandWithUkraine
Installing codeigniter4/appstarter (v4.3.6)
Failed to download codeigniter4/appstarter from dist: The zip extension and unzip/7z commands are both missing, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
Now trying to download from source
- Syncing codeigniter4/appstarter (v4.3.6) into cache
- Installing codeigniter4/appstarter (v4.3.6): Cloning da394c22f8 from cache
Created project in /var/www/html/testapp
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- codeigniter4/framework[4.0.0, ..., v4.2.10] require ext-curl * -> it is missing from your system. Install or enable PHP's curl extension.
- codeigniter4/framework[v4.2.11, ..., v4.3.6] require ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
- Root composer.json requires codeigniter4/framework ^4.0 -> satisfiable by codeigniter4/framework[4.0.0, ..., v4.3.6].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.1/cli/php.ini
- /etc/php/8.1/cli/conf.d/10-opcache.ini
- /etc/php/8.1/cli/conf.d/10-pdo.ini
- /etc/php/8.1/cli/conf.d/20-calendar.ini
- /etc/php/8.1/cli/conf.d/20-ctype.ini
- /etc/php/8.1/cli/conf.d/20-exif.ini
- /etc/php/8.1/cli/conf.d/20-ffi.ini
- /etc/php/8.1/cli/conf.d/20-fileinfo.ini
- /etc/php/8.1/cli/conf.d/20-ftp.ini
- /etc/php/8.1/cli/conf.d/20-gettext.ini
- /etc/php/8.1/cli/conf.d/20-iconv.ini
- /etc/php/8.1/cli/conf.d/20-phar.ini
- /etc/php/8.1/cli/conf.d/20-posix.ini
- /etc/php/8.1/cli/conf.d/20-readline.ini
- /etc/php/8.1/cli/conf.d/20-shmop.ini
- /etc/php/8.1/cli/conf.d/20-sockets.ini
- /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.1/cli/conf.d/20-sysvsem.ini
- /etc/php/8.1/cli/conf.d/20-sysvshm.ini
- /etc/php/8.1/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-curl --ignore-platform-req=ext-intl` to temporarily ignore these required extensions.
it is missing from your system. Install or enable PHP’s curl extension.
it is missing from your system. Install or enable PHP’s intl extension.
まずはcurlがないと怒られているのでcurlをインストールする。下記コマンドでインストール。自動的に有効化される。
sudo apt-get install php-curl
ちなみにphpのライブラリ”php-curl”がきちんとインストールされたか確認するには下記コマンド。
php -m | grep curl
intlもないと怒られているのでintlをインストール。
sudo apt-get install php-intl
同様にインストールされたか確認コマンド。
php -m | grep intl
(2回目)CodeIgniter4をインストール
$ composer create-project codeigniter4/appstarter testapp
(エラー)The zip extension and unzip/7z commands are both missing, skipping.
実行結果
user001@DESKTOP-5PN5FNJ:~$ composer create-project codeigniter4/appstarter testapp
Creating a "codeigniter4/appstarter" project at "./testapp"
Info from https://repo.packagist.org: #StandWithUkraine
Installing codeigniter4/appstarter (v4.3.6)
Failed to download codeigniter4/appstarter from dist: The zip extension and unzip/7z commands are both missing, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
Now trying to download from source
- Syncing codeigniter4/appstarter (v4.3.6) into cache
- Installing codeigniter4/appstarter (v4.3.6): Cloning da394c22f8 from cache
Created project in /home/user001/testapp
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit[9.1.0, ..., 9.2.6] require php ^7.3 -> your php version (8.1.2) does not satisfy that requirement.
- phpunit/phpunit[9.3.0, ..., 9.6.9] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
- Root composer.json requires phpunit/phpunit ^9.1 -> satisfiable by phpunit/phpunit[9.1.0, ..., 9.6.9].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.1/cli/php.ini
- /etc/php/8.1/cli/conf.d/10-opcache.ini
- /etc/php/8.1/cli/conf.d/10-pdo.ini
- /etc/php/8.1/cli/conf.d/20-calendar.ini
- /etc/php/8.1/cli/conf.d/20-ctype.ini
- /etc/php/8.1/cli/conf.d/20-curl.ini
- /etc/php/8.1/cli/conf.d/20-exif.ini
- /etc/php/8.1/cli/conf.d/20-ffi.ini
- /etc/php/8.1/cli/conf.d/20-fileinfo.ini
- /etc/php/8.1/cli/conf.d/20-ftp.ini
- /etc/php/8.1/cli/conf.d/20-gettext.ini
- /etc/php/8.1/cli/conf.d/20-iconv.ini
- /etc/php/8.1/cli/conf.d/20-intl.ini
- /etc/php/8.1/cli/conf.d/20-phar.ini
- /etc/php/8.1/cli/conf.d/20-posix.ini
- /etc/php/8.1/cli/conf.d/20-readline.ini
- /etc/php/8.1/cli/conf.d/20-shmop.ini
- /etc/php/8.1/cli/conf.d/20-sockets.ini
- /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.1/cli/conf.d/20-sysvsem.ini
- /etc/php/8.1/cli/conf.d/20-sysvshm.ini
- /etc/php/8.1/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-dom` to temporarily ignore these required extensions.
これはComposerがzipファイルを展開時にはOS提供のunzipユーティリティもしくはphpのzipエクステンションを使用しているが、これらの機能が見つからなかったために出たエラー。
sudo apt-get install zip unzip php8.1-zip
(3回目)CodeIgniter4をインストール
$ composer create-project codeigniter4/appstarter testapp
(エラー)it is missing from your system. Install or enable PHP’s dom extension.
実行結果
user001@DESKTOP-5PN5FNJ:~$ composer create-project codeigniter4/appstarter testapp1
Creating a "codeigniter4/appstarter" project at "./testapp1"
Info from https://repo.packagist.org: #StandWithUkraine
Installing codeigniter4/appstarter (v4.3.6)
- Downloading codeigniter4/appstarter (v4.3.6)
- Installing codeigniter4/appstarter (v4.3.6): Extracting archive
Created project in /home/user001/testapp1
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit[9.1.0, ..., 9.2.6] require php ^7.3 -> your php version (8.1.2) does not satisfy that requirement.
- phpunit/phpunit[9.3.0, ..., 9.6.9] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
- Root composer.json requires phpunit/phpunit ^9.1 -> satisfiable by phpunit/phpunit[9.1.0, ..., 9.6.9].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.1/cli/php.ini
- /etc/php/8.1/cli/conf.d/10-opcache.ini
- /etc/php/8.1/cli/conf.d/10-pdo.ini
- /etc/php/8.1/cli/conf.d/20-calendar.ini
- /etc/php/8.1/cli/conf.d/20-ctype.ini
- /etc/php/8.1/cli/conf.d/20-curl.ini
- /etc/php/8.1/cli/conf.d/20-exif.ini
- /etc/php/8.1/cli/conf.d/20-ffi.ini
- /etc/php/8.1/cli/conf.d/20-fileinfo.ini
- /etc/php/8.1/cli/conf.d/20-ftp.ini
- /etc/php/8.1/cli/conf.d/20-gettext.ini
- /etc/php/8.1/cli/conf.d/20-iconv.ini
- /etc/php/8.1/cli/conf.d/20-intl.ini
- /etc/php/8.1/cli/conf.d/20-phar.ini
- /etc/php/8.1/cli/conf.d/20-posix.ini
- /etc/php/8.1/cli/conf.d/20-readline.ini
- /etc/php/8.1/cli/conf.d/20-shmop.ini
- /etc/php/8.1/cli/conf.d/20-sockets.ini
- /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.1/cli/conf.d/20-sysvsem.ini
- /etc/php/8.1/cli/conf.d/20-sysvshm.ini
- /etc/php/8.1/cli/conf.d/20-tokenizer.ini
- /etc/php/8.1/cli/conf.d/20-zip.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-dom` to temporarily ignore these required extensions.
いろいろ出てはいるけど、まずはDOM Extensionについて対応。
sudo apt-get install php-xml
(4回目)CodeIgniter4をインストール
$ composer create-project codeigniter4/appstarter testapp
(エラー)require ext-mbstring * -> it is missing from your system. Install or enable PHP’s mbstring extension.
実行結果(抜粋)
require ext-mbstring * -> it is missing from your system. Install or enable PHP's mbstring extension.
不足しているmbstringをインストール。
sudo apt-get install php-mbstring
(5回目)CodeIgniter4をインストール⇒成功
必要なものが全部そろったようでようやくインストール成功。
user001@DESKTOP-5PN5FNJ:~$ composer create-project codeigniter4/appstarter testapp5
Creating a "codeigniter4/appstarter" project at "./testapp5"
Installing codeigniter4/appstarter (v4.3.6)
- Installing codeigniter4/appstarter (v4.3.6): Extracting archive
Created project in /home/user001/testapp5
Loading composer repositories with package information
Updating dependencies
Lock file operations: 35 installs, 0 updates, 0 removals
- Locking codeigniter4/framework (v4.3.6)
- Locking doctrine/instantiator (2.0.0)
- Locking fakerphp/faker (v1.23.0)
- Locking laminas/laminas-escaper (2.12.0)
- Locking mikey179/vfsstream (v1.6.11)
- Locking myclabs/deep-copy (1.11.1)
- Locking nikic/php-parser (v4.15.5)
- Locking phar-io/manifest (2.0.3)
- Locking phar-io/version (3.2.1)
- Locking phpunit/php-code-coverage (9.2.26)
- Locking phpunit/php-file-iterator (3.0.6)
- Locking phpunit/php-invoker (3.1.1)
- Locking phpunit/php-text-template (2.0.4)
- Locking phpunit/php-timer (5.0.3)
- Locking phpunit/phpunit (9.6.9)
- Locking psr/container (2.0.2)
- Locking psr/log (1.1.4)
- Locking sebastian/cli-parser (1.0.1)
- Locking sebastian/code-unit (1.0.8)
- Locking sebastian/code-unit-reverse-lookup (2.0.3)
- Locking sebastian/comparator (4.0.8)
- Locking sebastian/complexity (2.0.2)
- Locking sebastian/diff (4.0.5)
- Locking sebastian/environment (5.1.5)
- Locking sebastian/exporter (4.0.5)
- Locking sebastian/global-state (5.0.5)
- Locking sebastian/lines-of-code (1.0.3)
- Locking sebastian/object-enumerator (4.0.4)
- Locking sebastian/object-reflector (2.0.4)
- Locking sebastian/recursion-context (4.0.5)
- Locking sebastian/resource-operations (3.0.3)
- Locking sebastian/type (3.2.1)
- Locking sebastian/version (3.0.2)
- Locking symfony/deprecation-contracts (v3.3.0)
- Locking theseer/tokenizer (1.2.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 35 installs, 0 updates, 0 removals
- Downloading psr/log (1.1.4)
- Downloading laminas/laminas-escaper (2.12.0)
- Downloading codeigniter4/framework (v4.3.6)
- Downloading symfony/deprecation-contracts (v3.3.0)
- Downloading psr/container (2.0.2)
- Downloading fakerphp/faker (v1.23.0)
- Downloading mikey179/vfsstream (v1.6.11)
- Downloading sebastian/version (3.0.2)
- Downloading sebastian/type (3.2.1)
- Downloading sebastian/resource-operations (3.0.3)
- Downloading sebastian/recursion-context (4.0.5)
- Downloading sebastian/object-reflector (2.0.4)
- Downloading sebastian/object-enumerator (4.0.4)
- Downloading sebastian/global-state (5.0.5)
- Downloading sebastian/exporter (4.0.5)
- Downloading sebastian/environment (5.1.5)
- Downloading sebastian/diff (4.0.5)
- Downloading sebastian/comparator (4.0.8)
- Downloading sebastian/code-unit (1.0.8)
- Downloading sebastian/cli-parser (1.0.1)
- Downloading phpunit/php-timer (5.0.3)
- Downloading phpunit/php-text-template (2.0.4)
- Downloading phpunit/php-invoker (3.1.1)
- Downloading phpunit/php-file-iterator (3.0.6)
- Downloading theseer/tokenizer (1.2.1)
- Downloading nikic/php-parser (v4.15.5)
- Downloading sebastian/lines-of-code (1.0.3)
- Downloading sebastian/complexity (2.0.2)
- Downloading sebastian/code-unit-reverse-lookup (2.0.3)
- Downloading phpunit/php-code-coverage (9.2.26)
- Downloading phar-io/version (3.2.1)
- Downloading phar-io/manifest (2.0.3)
- Downloading myclabs/deep-copy (1.11.1)
- Downloading doctrine/instantiator (2.0.0)
- Downloading phpunit/phpunit (9.6.9)
- Installing psr/log (1.1.4): Extracting archive
- Installing laminas/laminas-escaper (2.12.0): Extracting archive
- Installing codeigniter4/framework (v4.3.6): Extracting archive
- Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
- Installing psr/container (2.0.2): Extracting archive
- Installing fakerphp/faker (v1.23.0): Extracting archive
- Installing mikey179/vfsstream (v1.6.11): Extracting archive
- Installing sebastian/version (3.0.2): Extracting archive
- Installing sebastian/type (3.2.1): Extracting archive
- Installing sebastian/resource-operations (3.0.3): Extracting archive
- Installing sebastian/recursion-context (4.0.5): Extracting archive
- Installing sebastian/object-reflector (2.0.4): Extracting archive
- Installing sebastian/object-enumerator (4.0.4): Extracting archive
- Installing sebastian/global-state (5.0.5): Extracting archive
- Installing sebastian/exporter (4.0.5): Extracting archive
- Installing sebastian/environment (5.1.5): Extracting archive
- Installing sebastian/diff (4.0.5): Extracting archive
- Installing sebastian/comparator (4.0.8): Extracting archive
- Installing sebastian/code-unit (1.0.8): Extracting archive
- Installing sebastian/cli-parser (1.0.1): Extracting archive
- Installing phpunit/php-timer (5.0.3): Extracting archive
- Installing phpunit/php-text-template (2.0.4): Extracting archive
- Installing phpunit/php-invoker (3.1.1): Extracting archive
- Installing phpunit/php-file-iterator (3.0.6): Extracting archive
- Installing theseer/tokenizer (1.2.1): Extracting archive
- Installing nikic/php-parser (v4.15.5): Extracting archive
- Installing sebastian/lines-of-code (1.0.3): Extracting archive
- Installing sebastian/complexity (2.0.2): Extracting archive
- Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
- Installing phpunit/php-code-coverage (9.2.26): Extracting archive
- Installing phar-io/version (3.2.1): Extracting archive
- Installing phar-io/manifest (2.0.3): Extracting archive
- Installing myclabs/deep-copy (1.11.1): Extracting archive
- Installing doctrine/instantiator (2.0.0): Extracting archive
- Installing phpunit/phpunit (9.6.9): Extracting archive
17 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
27 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
開発用Webサーバの起動(sparkコマンド)
ターミナルからsparkコマンドを実行すると開発用Webサーバを起動できる。sparkコマンドはCodeIgniter4から導入されたもの。sparkコマンドはプロジェクトルートで実行する。(上記の例でいうとtestappディレクトリ)
$ php spark serve
ブラウザからhttp://localhost:8080/にアクセスしてWelcome ページが表示されたらOK。
★CodeIngniter4インストールに必要となったものまとめ
本環境下では、CodeIgniter4のインストールということだけでいうと以下が必要でした。
- php-curl
- php-intl
- zip unzip php8.1-zip
- php-xml
- php-mbstring