Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

500エラー

PHPでエラーがみたい

php.iniファイルで

error_reporting  =  E_ALL
display_errors On
display_startup_errors = On

公開用サーバではlog_errorsでログでみるべき。

internal error 500

新しくプロジェクトを作ったところそのようなエラーがでた。
ログを確認したところ

 PHP Fatal error:  require(): Failed opening required '/Applications/MAMP/htdocs/hogemysql/vendor/autoload.php' (include_path='.:/Applications/MAMP/bin/php/php7.1.1/lib/php') in /Applications/MAMP/htdocs/hogemysql/webroot/index.php on line 27

PHP Warning:  require(/Applications/MAMP/htdocs/hogemysql/vendor/autoload.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/hogemysql/webroot/index.php on line 27

つまりautoload.phpがないといわれている。

同様の問題と思わしきページ
chaika.hatenablog.com

たしかにログをみてみると

$ php composer.phar create-project --prefer-dist cakephp/app hogemysql
Installing cakephp/app (3.4.2)
  - Installing cakephp/app (3.4.2): Downloading (100%)         
Created project in hogemysql
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
    - cakephp/cakephp 3.4.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.4.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.4.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.4.4 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.4.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - cakephp/cakephp 3.4.2 requires lib-icu >=4.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - cakephp/cakephp 3.4.1 requires lib-icu >=4.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - cakephp/cakephp 3.4.0 requires lib-icu >=4.8 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.
    - Installation request for cakephp/cakephp 3.4.* -> satisfiable by cakephp/cakephp[3.4.0, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7].

とintlがないと言われている。
qiita.com

の手順でやってみた。

icu4cインストール(Unicode 関連の処理を行うためのオープンソースのライブラリ)

$ brew install icu4c

autoconfインストール(https://ja.wikipedia.org/wiki/Autotools#autoconf)
が、うまくいかない。

Error: No available formula with the name "icu4cautoconf" 
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
==> You haven't updated Homebrew in a while.

brew updateしようとしたが

Error: /usr/local must be writable!


qiita.com

とありあえず

brew doctor

してみた。
それにしたがい

sudo chown -R $(whoami) /usr/local

をする。

brew update

が実行できたが

Error: update-report should not be called directly!


もう一度

brew install autoconf
$ sudo pecl update-channels
$ sudo pecl install intl 
sudo: pecl: command not found

遠回りしている気がしたので

brew search intl
intltool
homebrew/php/php53-intl    homebrew/php/php55-intl    homebrew/php/php71-intl
homebrew/php/php54-intl    homebrew/php/php56-intl    homebrew/php/php70-intl
brew install homebrew/php/php71-intl

webアプリのフォルダで

composer install

これでアクセスしたところ表示が500から

Could not load configuration file: /Applications/MAMP/htdocs/hogemysql/config/app.php

に変わった。
もう一度

composer install

したところ

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/cache
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/cache/models
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/cache/persistent
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/cache/views
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/sessions
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp/tests
Permissions set on /Applications/MAMP/htdocs/hogemysql/tmp
Permissions set on /Applications/MAMP/htdocs/hogemysql/logs
Updated Security.salt value in config/app.php

となり、無事アクセスが成功した。


whoamiとは

whoami - Wikipedia

広告を非表示にする