さとうナイトニッポン

やったことのメモとか日々の雑記とか

composerでプロジェクト作成したら色々ないって怒られた

CakePHPで新しくプロジェクトを作成

composer self-update && composer create-project --prefer-dist cakephp/app app

以下のエラーが発生

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

  Problem 1
    - cakephp/cakephp 3.5.9 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.8 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.11 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.10 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.5.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - Installation request for cakephp/cakephp 3.5.* -> satisfiable by cakephp/cakephp[3.5.0, 3.5.1, 3.5.10, 3.5.11, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.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-json.ini
    - /etc/php.d/20-mbstring.ini
    - /etc/php.d/20-mcrypt.ini
    - /etc/php.d/20-pdo.ini
    - /etc/php.d/20-phar.ini
    - /etc/php.d/20-posix.ini
    - /etc/php.d/20-shmop.ini
    - /etc/php.d/20-simplexml.ini
    - /etc/php.d/20-sockets.ini
    - /etc/php.d/20-sqlite3.ini
    - /etc/php.d/20-sysvmsg.ini
    - /etc/php.d/20-sysvsem.ini
    - /etc/php.d/20-sysvshm.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-pdo_sqlite.ini
    - /etc/php.d/30-wddx.ini
    - /etc/php.d/30-xmlreader.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

the requested PHP extension intl is missing from your system.PHP extension intl ないよ😭の意

ext-intlでググると以下の記事がヒット CakePHP3.0をインストールしてみる(自分用めもめも - Qiita こちらに沿ってphp.intlをインストール

sudo pecl install intl
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading intl-3.0.0.tgz ...
Starting to download intl-3.0.0.tgz (248,200 bytes)
....................................................done: 248,200 bytes
150 source files, building
.
.
.
.
.
checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
ERROR: `/var/tmp/intl/configure --with-php-config=/usr/bin/php-config --with-icu-dir=DEFAULT' failed

またしてもエラー

ERROR: `/var/tmp/intl/configure --with-php-config=/usr/bin/php-config --with-icu-dir=DEFAULT' failed

why? ComposerでCakephp3をインストールしようとしてハマった件 | Into The World そもそもintl.soない?

$sudo find / -name *intl.so
$

ないやんけ intl.soをインストール

$sudo pecl install intl

→エラー

なんでやねん そもそもどこにあんねん

$sudo find / -name *intl.so
/opt/remi/php70/root/usr/lib64/php/modules/intl.so

php.iniに

extension=/opt/remi/php70/root/usr/lib64/php/modules/intl.so

を追加してservice httpd restart

[root@localhost hello.jp]# php -i | grep intl
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

通った☺

再度プロジェクト作成

  1. ブラウザから該当ページアクセス この時点ではドメインアクセス時にapacheのテストページが表示される。 ドメイン/app(/index.php) がcakeのルートになっているらしい?
Database driver Cake\Database\Driver\Mysql cannot be used due to a missing PHP extension or unmet dependency

と表示されている

CakePHP3でデータベースに接続できなくて困った – 完璧になんてなれない Mysqlが有効になっていないらしい

そもそもある?

[root@localhost webroot]# php -m | grep mysqlnd
[root@localhost webroot]#

なんで? 通常phpインストール時にmysqlは一緒にインストールされる認識だった

インストール

$ yum install yum install --enablerepo=remi,remi-php70 php-mysqlnd


インストール:
  php-mysqlnd.x86_64 0:7.0.27-1.el6.remi

依存性を更新しました:
  php.x86_64 0:7.0.27-1.el6.remi
  php-cli.x86_64 0:7.0.27-1.el6.remi
  php-common.x86_64 0:7.0.27-1.el6.remi
  php-devel.x86_64 0:7.0.27-1.el6.remi
  php-gd.x86_64 0:7.0.27-1.el6.remi
  php-json.x86_64 0:7.0.27-1.el6.remi
  php-mbstring.x86_64 0:7.0.27-1.el6.remi
  php-mcrypt.x86_64 0:7.0.27-1.el6.remi
  php-pdo.x86_64 0:7.0.27-1.el6.remi
  php-process.x86_64 0:7.0.27-1.el6.remi
  php-xml.x86_64 0:7.0.27-1.el6.remi

完了しました!
[root@localhost webroot]# php -m | grep mysqlnd
mysqlnd

インストールされた場所を確認

[root@localhost webroot]# sudo find / -name *mysql.so
/usr/lib64/php/modules/pdo_mysql.so

php.iniに以下追加

extension=/usr/lib64/php/modules/pdo_mysql.so

php.iniを更新したのでapache再起動してcake serverを実行(/bin/cake server)

vagrant@localhost webroot]$ sudo service httpd restart
httpd を停止中:                                            [  OK
httpd を起動中:                                            [  OK
[vagrant@localhost webroot]$ cake server
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/l                    s/pdo_mysql.so' - /usr/lib64/php/modules/pdo_mysql.so: undefined                     _allocator in Unknown on line 0

またエラー・・・ まずこちら

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/ls/pdo_mysql.so' - /usr/lib64/php/modules/pdo_mysql.so: undefined_allocator in Unknown on line 0

/usr/lib64/php/modules/にpdo_mysql.soがない?

[root@localhost webroot]# sudo find / -name *mysql.so
/usr/lib64/php/modules/pdo_mysql.so
/usr/lib64/php-zts/modules/pdo_mysql.so

あるじゃん!なんでや 教えて先生

php.iniに追加したやつをコメントアウトしてcake server

ドメイン/app/にアクセス

Database Error

  1. DB設定 rootでmysql ログイン
mysql> create database hello_db;
Query OK, 1 row affected (0.10 sec)

mysql> grant all on hello_db.* to vagrant@localhost identified by 'hello_db';
Query OK, 0 rows affected (0.10 sec)

ブラウザ更新

SQLSTATE[HY000]: General error: 8 attempt to write a readonly database

エラー

以下の権限変更

chmod 777 app/tmp/debug_kit.sqlite

cakeのテストページが表示された