CodeIgniter4 / Composer on Cent OS Stream9, PHP8.1

PHP

CodeIgniter4
https://codeigniter.com/

CodeIgniter 4 is the latest version of the framework, intended for use with PHP 7.3+(including 8.1).
The initial release was February 24, 2020. The current version is v4.2.5.

PHP8.1で v4.2.5を使ってみます。

Composer Installation — CodeIgniter 4.2.5 documentation

composerで入れるのが良いかな?全然使ってないけど。

Composerをインストール

Composer
A Dependency Manager for PHP

ダウンロード

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

グローバルで使えるように

sudo mv composer.phar /usr/local/bin/composer
$ composer -V
Composer version 2.4.1 2022-08-20 11:44:50

できたようです。

CodeIgniterをインストール

コマンドで

composer create-project codeigniter4/appstarter ~/apps/app

なんかエラー

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - codeigniter4/framework[4.0.0, ..., v4.2.5] 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.2.5].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php.d/10-opcache.ini
    - /etc/php.d/20-bz2.ini
    - /etc/php.d/20-calendar.ini
    - /etc/php.d/20-ctype.ini
    - /etc/php.d/20-curl.ini
    - /etc/php.d/20-dom.ini
    - /etc/php.d/20-exif.ini
    - /etc/php.d/20-fileinfo.ini
    - /etc/php.d/20-ftp.ini
    - /etc/php.d/20-gd.ini
    - /etc/php.d/20-gettext.ini
    - /etc/php.d/20-iconv.ini
    - /etc/php.d/20-mbstring.ini
    - /etc/php.d/20-mysqlnd.ini
    - /etc/php.d/20-pdo.ini
    - /etc/php.d/20-phar.ini
    - /etc/php.d/20-simplexml.ini
    - /etc/php.d/20-sockets.ini
    - /etc/php.d/20-sodium.ini
    - /etc/php.d/20-sqlite3.ini
    - /etc/php.d/20-tokenizer.ini
    - /etc/php.d/20-xml.ini
    - /etc/php.d/20-xmlwriter.ini
    - /etc/php.d/20-xsl.ini
    - /etc/php.d/30-mcrypt.ini
    - /etc/php.d/30-mysqli.ini
    - /etc/php.d/30-pdo_mysql.ini
    - /etc/php.d/30-pdo_sqlite.ini
    - /etc/php.d/30-xmlreader.ini
    - /etc/php.d/40-imagick.ini
    - /etc/php.d/40-memcache.ini
    - /etc/php.d/50-mysql.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-intl` to temporarily ignore these required extensions.

言われるがまま php –ini してみたけど関係ない

$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/10-opcache.ini,
/etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
/etc/php.d/20-ctype.ini,
/etc/php.d/20-curl.ini,
/etc/php.d/20-dom.ini,
/etc/php.d/20-exif.ini,
/etc/php.d/20-fileinfo.ini,
/etc/php.d/20-ftp.ini,
/etc/php.d/20-gd.ini,
/etc/php.d/20-gettext.ini,
/etc/php.d/20-iconv.ini,
/etc/php.d/20-mbstring.ini,
/etc/php.d/20-mysqlnd.ini,
/etc/php.d/20-pdo.ini,
/etc/php.d/20-phar.ini,
/etc/php.d/20-simplexml.ini,
/etc/php.d/20-sockets.ini,
/etc/php.d/20-sodium.ini,
/etc/php.d/20-sqlite3.ini,
/etc/php.d/20-tokenizer.ini,
/etc/php.d/20-xml.ini,
/etc/php.d/20-xmlwriter.ini,
/etc/php.d/20-xsl.ini,
/etc/php.d/30-mcrypt.ini,
/etc/php.d/30-mysqli.ini,
/etc/php.d/30-pdo_mysql.ini,
/etc/php.d/30-pdo_sqlite.ini,
/etc/php.d/30-xmlreader.ini,
/etc/php.d/40-imagick.ini,
/etc/php.d/40-memcache.ini,
/etc/php.d/50-mysql.ini

php-intlというのをインストールしろと言っているらしい

 sudo dnf install php-intl
[sudo] junichi のパスワード:
メタデータの期限切れの最終確認: 0:09:12 時間前の 2022年09月02日 05時07分50秒 に実施しました。
依存関係が解決しました。
========================================================================================================================================================================================================
 パッケージ                                      アーキテクチャー                          バージョン                                             リポジトリー                                    サイズ
========================================================================================================================================================================================================
インストール:
 php-intl                                        x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    208 k
アップグレード:
 php                                             x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    1.7 M
 php-cli                                         x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    5.2 M
 php-common                                      x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    828 k
 php-devel                                       x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    741 k
 php-fpm                                         x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    1.8 M
 php-gd                                          x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                     64 k
 php-mbstring                                    x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    516 k
 php-mysqlnd                                     x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    216 k
 php-opcache                                     x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    603 k
 php-pdo                                         x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    114 k
 php-sodium                                      x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                     57 k
 php-xml                                         x86_64                                    8.1.10-1.el9.remi                                      remi-modular                                    204 k
依存関係のインストール:
 libicu71                                        x86_64                                    71.1-1.el9.remi                                        remi-safe                                        10 M
アップグレード済み:
  php-8.1.10-1.el9.remi.x86_64           php-cli-8.1.10-1.el9.remi.x86_64         php-common-8.1.10-1.el9.remi.x86_64     php-devel-8.1.10-1.el9.remi.x86_64      php-fpm-8.1.10-1.el9.remi.x86_64   
  php-gd-8.1.10-1.el9.remi.x86_64        php-mbstring-8.1.10-1.el9.remi.x86_64    php-mysqlnd-8.1.10-1.el9.remi.x86_64    php-opcache-8.1.10-1.el9.remi.x86_64    php-pdo-8.1.10-1.el9.remi.x86_64   
  php-sodium-8.1.10-1.el9.remi.x86_64    php-xml-8.1.10-1.el9.remi.x86_64        
インストール済み:
  libicu71-71.1-1.el9.remi.x86_64                                                                   php-intl-8.1.10-1.el9.remi.x86_64                                                                  

完了しました!

問題なくインストール

$  composer create-project codeigniter4/appstarter ~/apps/app
色々
  - Installing doctrine/instantiator (1.4.1): Extracting archive
  - Installing phpunit/phpunit (9.5.24): Extracting archive
14 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating 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

大丈夫っぽい

更新とか

$ composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating 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

とくに更新なし。

初期設定

Running Your App — CodeIgniter 4.2.5 documentation

さっそく動かす

app/Config/App.php の baseURLを自分のURLに変更

nginx -> php-fpm -> codeigniter と繋がりました^^

他の設定

コメント

タイトルとURLをコピーしました