nakatievent / my_baby_diary_app

0 stars 0 forks source link

Bootstrap使用可能な設定にする(Laravel BreezeからLaravel uiへの設定を変更する)。 #42

Open nakatievent opened 3 years ago

nakatievent commented 3 years ago

Laravel BreezeからLaravel uiヘ設定を変更する

Laravel8からはログイン機能等をLaravel BreezeもしくはLaravel Jetstreemで実装できるようになったそうだが、それだとフロントの実装をTailwind CSSというフレームワークで書かなければならない。今はできるだけ早めにポートフォリオを作成しなければならないのでBootstrapで実装していく。なので、Laravel7とかで使用されていたLaravel uiに設定を戻していく。

Laravel Breezeへの設定方法は下記のURL参照↓

ログイン機能の実装(Laravel Breeze)

今回は下記の記事を参考にLaravel uiに設定を変更していく。

公式リファレンスLaravel8.x + Bootstrap + FontAwesomeを使うをみながらBootstrapを使用できる設定にしていく。

nakatievent commented 3 years ago

Bootstarpを設定していく

docker-compose exec app bash でappコンテナ内に入り、

composer require laravel/uiすると

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

と出たので、

COMPOSER_MEMORY_LIMIT=-1 composer require laravel/uiでリミットを外して実行していく。

そして、php artisan ui bootstrapを順調に実行していく。

php artisan ui bootstrap --authを実行したところで、

Bootstrap scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.

 The [auth/login.blade.php] view already exists. Do you want to replace it? (yes/no) [no]:
 >
 The [auth/register.blade.php] view already exists. Do you want to replace it? (yes/no) [no]:
 >
 The [layouts/app.blade.php] view already exists. Do you want to replace it? (yes/no) [no]:
 >

と出たので、全部Yesと記入していく。

すると、 Authentication scaffolding generated successfully. と表示され成功した。

これでTaiwlandCSSとおさらば(したはず)。 TailwindCSSには興味あるが、今は時間がないので今度勉強する。 とりあえず、今はTailwindCSSはファイルは見たくない。。。

nakatievent commented 3 years ago

エラー発生。

npm install && npm run devを実行しようとするとエラーが。

[Docker] Node.js以外のコンテナに追加でNode.jsの最新版をインストールするDockerfileの記述を参考に、

下記のように、Dockerfileの中身に

RUN curl -SL https://deb.nodesource.com/setup_15.x | bash
RUN apt-get install -y nodejs

を追加したところ成功した。

このエラーを解消するまで5時間くらいかかってシンドイ。。。

あと、ビルドがめっちゃ長い。。。

FROM php:7.4-fpm-buster
SHELL ["/bin/bash", "-oeux", "pipefail", "-c"]

ENV COMPOSER_ALLOW_SUPERUSER=1 \
  COMPOSER_HOME=/composer

COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer

RUN apt-get update && \
  apt-get -y install git unzip libzip-dev libicu-dev libonig-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* && \
  docker-php-ext-install intl pdo_mysql zip bcmath

RUN curl -SL https://deb.nodesource.com/setup_15.x | bash
RUN apt-get install -y nodejs

COPY ./php.ini /usr/local/etc/php/php.ini

WORKDIR /work
nakatievent commented 3 years ago

composerからlaravel/breezeの削除

composerからアンインストールできることを知って下記のコードを実行した。

composer remove --update-with-dependencies laravel/breeze

下記の結果を見ると、laravel/uiもアンインストールされているっぽいので再度上記のコードを実行してBootstrap使用可能な設定にすることができた。

You are using the deprecated option "update-with-dependencies". This is now default behaviour. The --no-update-with-dependencies option can be used to remove a package without its dependencies.
laravel/breeze could not be found in require but it is present in require-dev
Do you want to remove it from require-dev [yes]? yes
Dependency "laravel/framework" is also a root requirement, but is not explicitly allowed. Ignoring.
Dependency "laravel/framework" is also a root requirement, but is not explicitly allowed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 2 removals
  - Removing laravel/ui (v3.2.0)
  - Removing laravel/breeze (v1.1.3)
Writing lock file
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   RuntimeException