PHP - Laravel - インストール - FreeBSD 12.2 RELEASE - インストール

クラウディア 
1. 概要
2. インストール
3. プロジェクト作成
4. fileinfo インストール
5. 再インストール
6. 所有権の設定

1. 概要

インストール 7.x Laravel
 に掲載してある、最初の手順でやってみたのですよ。

2. インストール

 「composer」を「root」ユーザで動かそうとすると

Changed current directory to /root/.composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
 と怒られちゃうので、ログインユーザで操作します。

$ composer global require laravel/installer
Changed current directory to /home/hogehoge/.composer
Using version ^4.0 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-php80 (v1.22.0): Downloading (100%)
  - Installing symfony/process (v5.2.1): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.22.0): Downloading (100%)
  - Installing symfony/polyfill-intl-normalizer (v1.22.0): Downloading (100%)
  - Installing symfony/polyfill-intl-grapheme (v1.22.0): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.22.0): Downloading (100%)
  - Installing symfony/string (v5.2.1): Downloading (100%)
  - Installing psr/container (1.0.0): Downloading (100%)
  - Installing symfony/service-contracts (v2.2.0): Downloading (100%)
  - Installing symfony/polyfill-php73 (v1.22.0): Downloading (100%)
  - Installing symfony/console (v5.2.1): Downloading (100%)
  - Installing laravel/installer (v4.0.0): Downloading (100%)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing psr/log (For using the console logger)
Writing lock file
Generating autoload files
10 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
 少し、時間は、かかりますが、これは、すんなり通ります(実際は、すごくカラフル)。  パスを通しておきます(「~/.cshrc」や「~/.bashrc」に記述すべき)。  ここでは、「tcsh」で

set path = ($path ~/.composer/vendor/bin )

3. プロジェクト作成

 次に、ユーザに書き込み権限のあるディレクトリでプロジェクトを作成します。  プロジェクト名を「laravel」として(ちょっとややこしいかな?)。  ログインユーザで

laravel new laravel
 (先頭の「laravel」がコマンドで、末尾の「laravel」がプロジェクト名)  すると

 _                               _
| |                             | |
| |     __ _ _ __ __ ___   _____| |
| |    / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V /  __/ |
|______\__,_|_|  \__,_| \_/ \___|_|


In NewCommand.php line 73:

  The Laravel installer requires PHP 7.3.0 or greater. Please use "composer create-project laravel/laravel" inst
  ead.


new [--dev] [--jet] [-f|--force] [--] [<name>]
 てなことを言われる。  デフォルトでは、「7.3」を欲しがっているようです。  言われるがまま、今度は

composer create-project laravel/laravel
 すると

Creating a "laravel/laravel" project at "./laravel"
Installing laravel/laravel (v7.30.1)
  - Installing laravel/laravel (v7.30.1): Downloading (100%)
Created project in /usr/local/www/laravel
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
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
    - laravel/framework 7.x-dev requires league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.x-dev].

・・・	略	・・・

    - league/flysystem 1.1.0 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - Installation request for laravel/framework ^7.29 -> satisfiable by laravel/framework[7.x-dev, v7.29.0, v7.29.1, v7.29.2, v7.29.3, v7.30.0, v7.30.1].

  To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php.ini
    - /usr/local/etc/php/ext-10-opcache.ini

・・・	略	・・・

    - /usr/local/etc/php/ext-30-xmlreader.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
 で、しばらく悩みましたがな・・・。  どうも「ext-fileinfo」がないのだという結論に・・・。

4. fileinfo インストール

 どうやらこれらしいと目星をつけて・・・。  「root」ユーザで。

cd /usr/ports/sysutils/php72-fileinfo
make
make install

5. 再インストール

 再度、ログインユーザで。  先ほどつくりかけのディレクトリは、全部消して・・・。

composer create-project laravel/laravel laravel --prefer-dist
 「laravel」の最初の二つは、パッケージ名で、後ろのひとつがプロジェクト名です。  今度は

Creating a "laravel/laravel" project at "./laravel"
Installing laravel/laravel (v7.30.1)
  - Installing laravel/laravel (v7.30.1): Loading from cache
Created project in /usr/local/www/laravel
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 100 installs, 0 updates, 0 removals
  - Installing voku/portable-ascii (1.5.6): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.22.0): Downloading (100%)

・・・	略	・・・

  - Installing myclabs/deep-copy (1.10.2): Downloading (100%)
  - Installing phpunit/phpunit (8.5.13): Downloading (100%)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)

・・・	略	・・・

phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
67 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.
 「successfully」つってるからうまくいったのかな。

6. 所有権の設定

 これ、実は、後ろの方にも書いちゃったので、重複しますが、いずれやる必要があるので・・・。  「Laravel」を動作させる上で、ログやキャッシュのフォルダは、「www」の所有権にしておかないと権限エラーになるものがあります。  このあたり、「smarty」あたりと同様ですな。  「root」ユーザ権限で、下記の設定を行います。

chown -R www:www /プロジェクトパス/bootstrap/cache
chown -R www:www /プロジェクトパス/storage/framework
chown -R www:www /プロジェクトパス/storage/logs
earthcar(アースカー)
ネットオークションの相場、統計、価格比較といえばオークファン