<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP アーカイブ - Sheltie&#039;s Garage</title>
	<atom:link href="https://sheltie-garage.xyz/category/%E6%8A%80%E8%A1%93%E7%B3%BB/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://sheltie-garage.xyz/category/技術系/php/</link>
	<description>趣味に生きる</description>
	<lastBuildDate>Sun, 15 Mar 2020 13:46:37 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://sheltie-garage.xyz/wp-content/uploads/2018/04/cropped-L927xrpq-32x32.jpg</url>
	<title>PHP アーカイブ - Sheltie&#039;s Garage</title>
	<link>https://sheltie-garage.xyz/category/技術系/php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>DockerでLiteSpeed Webサーバを構築してLaravelを実行する</title>
		<link>https://sheltie-garage.xyz/2020/03/docker%e3%81%a7litespeed-web%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6laravel%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 15 Mar 2020 13:04:58 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=1958</guid>

					<description><![CDATA[<p>新しいWebサービスを開発したいと思い、今回はWebサーバをLiteSpeedでやってみることにしました。が、新しいことはおおよそハマるので、結局調査開始からLaravel稼働まで1週間ほど費やしてしまいした・・・ Do [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2020/03/docker%e3%81%a7litespeed-web%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6laravel%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/">DockerでLiteSpeed Webサーバを構築してLaravelを実行する</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>新しいWebサービスを開発したいと思い、今回はWebサーバをLiteSpeedでやってみることにしました。<br>が、新しいことはおおよそハマるので、結局調査開始からLaravel稼働まで1週間ほど費やしてしまいした・・・</p>



<h2 class="wp-block-heading">Dockerfileとdocker-composeについて</h2>



<p>Docker Composeを利用して仮想サーバを管理します。<br>どちらのファイルも以下の<a href="https://github.com/sheltie-fusafusa/litespeed-laravel-docker" target="_blank" rel="noreferrer noopener" aria-label="GitHub (opens in a new tab)">GitHub</a>から取得可能です。</p>



<p>今回のディレクトリ構成は、以下のような感じです。</p>



<figure class="wp-block-image size-large"><img decoding="async" width="280" height="104" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-24.png" alt="" class="wp-image-1985"/></figure>



<h2 class="wp-block-heading">Docker buildからlaravelを動かすまで</h2>



<h4 class="wp-block-heading">イメージのビルド</h4>



<p>docker-compose.ymlファイルがあるディレクトリへ移動し、以下のコマンドでイメージのビルト、コンテナの起動を行います。</p>



<pre class="crayon-plain-tag">$ docker-compose build
$ docker-compose up -d</pre>



<h4 class="wp-block-heading">litespeed管理画面へのログイン</h4>



<p>コンテナが無事に起動したら、コンテナにログインし、初期パスワードを確認します。</p>



<pre class="crayon-plain-tag">$ winpty docker-compose exec web bash
[root@6c71de6daed0 lsws]# cat /usr/local/lsws/adminpasswd</pre>



<p>初期パスワードを確認したら、以下のURLから管理画面にログインします。<br><a href="https://localhost:7080/login.php">https://localhost:7080/login.php</a><br><br>初回アクセス時、SSL証明書の警告が表示されますが、自身の開発サーバなので構わずアクセスします。</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="658" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-1-1-1024x658.png" alt="" class="wp-image-1960" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-1-1-1024x658.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-1-1-300x193.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-1-1-768x494.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-1-1.png 1428w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">php7.4のインストール、バーチャルホスト、リスナーの設定</h4>



<p>デフォルトでphp7.3が入っていましたが、せっかくなのでphp7.4のバイナリをインストールします。<br>Dockerfileでは、php7.4バイナリのインストールに必要なパッケージも同時にインストールしています。<br>具体的な手順は、下記画像を参照してください。</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="446" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-2-1-1024x446.png" alt="" class="wp-image-1962" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-2-1-1024x446.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-2-1-300x131.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-2-1-768x335.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-2-1.png 1438w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="528" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-3-1-1024x528.png" alt="" class="wp-image-1963" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-3-1-1024x528.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-3-1-300x155.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-3-1-768x396.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-3-1.png 1438w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="483" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-4-1024x483.png" alt="" class="wp-image-1964" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-4-1024x483.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-4-300x141.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-4-768x362.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-4.png 1483w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="473" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-5-1024x473.png" alt="" class="wp-image-1965" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-5-1024x473.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-5-300x139.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-5-768x355.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-5.png 1482w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>phpのコンパイルシェルはセキュリティの関係でターミナルから実行してくれとのこと。<br>といっても、親切に実行シェルがフルパスで書いてあるので、コンテナに接続後、コピペしてエンターを押せばよいだけです。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="710" height="217" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-6.png" alt="" class="wp-image-1968" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-6.png 710w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-6-300x92.png 300w" sizes="auto, (max-width: 710px) 100vw, 710px" /></figure>



<p>上記表示になればコンパイル終了です。画面的にはあと1ステップ残ってそうですが、作業はこれで終わりです。</p>



<h4 class="wp-block-heading">バーチャルホストの作成</h4>



<p>laravel実行用にバーチャルホストを作成します。下記画像を参照してください。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="345" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-10-1024x345.png" alt="" class="wp-image-1969" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-10-1024x345.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-10-300x101.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-10-768x259.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-10.png 1494w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="585" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-11-1024x585.png" alt="" class="wp-image-1970" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-11-1024x585.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-11-300x171.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-11-768x438.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-11.png 1482w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>画面に映っている部分以外はすべてデフォルトです</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="669" height="74" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-12.png" alt="" class="wp-image-1971" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-12.png 669w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-12-300x33.png 300w" sizes="auto, (max-width: 669px) 100vw, 669px" /></figure>



<p>保存時にファイルがないエラーが出ますが、CLICK TO CREATE をクリックしファイル作成後に再度保存すれば大丈夫です。</p>



<h4 class="wp-block-heading">リスナーの作成</h4>



<p>ユーザーからのアクセスを受け付けるためのリスナーを作成します。設定は画像をば・・・</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="329" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-13-1024x329.png" alt="" class="wp-image-1972" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-13-1024x329.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-13-300x96.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-13-768x247.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-13.png 1501w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="473" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-14-1024x473.png" alt="" class="wp-image-1973" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-14-1024x473.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-14-300x139.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-14-768x355.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-14.png 1498w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="256" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-15-1024x256.png" alt="" class="wp-image-1974" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-15-1024x256.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-15-300x75.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-15-768x192.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-15.png 1499w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="428" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-16-1024x428.png" alt="" class="wp-image-1975" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-16-1024x428.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-16-300x125.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-16-768x321.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-16.png 1502w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="379" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-17-1024x379.png" alt="" class="wp-image-1976" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-17-1024x379.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-17-300x111.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-17-768x284.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-17.png 1492w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">バーチャルホストで利用するphpバージョンを指定</h4>



<p>デフォルトでphp7.4を利用するように設定を変更します。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="296" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-18-1024x296.png" alt="" class="wp-image-1978" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-18-1024x296.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-18-300x87.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-18-768x222.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-18.png 1493w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="455" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-19-1024x455.png" alt="" class="wp-image-1979" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-19-1024x455.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-19-300x133.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-19-768x342.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-19.png 1482w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="167" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-20-1024x167.png" alt="" class="wp-image-1980" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-20-1024x167.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-20-300x49.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-20-768x125.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-20.png 1260w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>設定を保存し、以下のURLにアクセス。<br><a rel="noreferrer noopener" aria-label="http://localhost:8088/ (opens in a new tab)" href="http://localhost:8088/" target="_blank">http://localhost:8088/</a><br><br>Test PHPでバージョンが7.4.3になっていることが確認できます。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="498" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-21-1024x498.png" alt="" class="wp-image-1981" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-21-1024x498.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-21-300x146.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-21-768x374.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-21.png 1169w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Laravelを動かす</h4>



<p>設定ファイル系をlaravel用に書き換えます。<br>(GUIからの変更方法がわからなかったので、ターミナルから直接編集しました)</p>



<p>Example バーチャルホストを参考に、以下の設定を挿入<br>編集ファイルは「/usr/local/lsws/conf/vhosts/laravel/vhconf.conf」です。</p>



<pre class="crayon-plain-tag">docRoot $VH_ROOT/public

context / {
  allowBrowse 1
  location $DOC_ROOT/
  rewrite  {
    RewriteFile .htaccess
  }
}</pre>



<p>.htaccessにlaravel公式のリライト設定を挿入します。<br>ファイルの場所は「/var/www/laravel/public/.htaccess」ですね。<br>litespeedはapacheのリライトと互換性があるとのことで、apache用の設定がそのまま使えます。</p>



<pre class="crayon-plain-tag">Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]</pre>



<p>ファイル設定後はGUIから再起動を行います。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="176" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-22-1024x176.png" alt="" class="wp-image-1983" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-22-1024x176.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-22-300x52.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-22-768x132.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-22.png 1476w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>後は、laravelプロジェクトを作成し、ホスト側のlaravelアプリケーションディレクトリにファイルを設置します。<br>今回はlaravel 配下に設置すればOK</p>



<h2 class="wp-block-heading">やっとLaravelのデフォルト画面が拝めます</h2>



<p>以上の設定でlitespeedでlaravelアプリが動くはずです。以下のURLにアクセスし、画面が表示されるか確認します。<br><a href="http://localhost:8080/" target="_blank" rel="noreferrer noopener" aria-label="http://localhost:8080/ (opens in a new tab)">http://localhost:8080/</a></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1015" height="645" src="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-23.png" alt="" class="wp-image-1984" srcset="https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-23.png 1015w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-23-300x191.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2020/03/Image-23-768x488.png 768w" sizes="auto, (max-width: 1015px) 100vw, 1015px" /></figure>



<p>やっとlaravelアプリが動きました！　隙間時間とはいえ、調査に1週間、この記事を書くのに3時間・・・長かった。</p>



<h2 class="wp-block-heading">でも、使うかどうかはわかりません</h2>



<p>まだ解決していない問題として、「サーバ設定の永続化」が残っています。<br>Dockerはご存じの通り、コンテナを破棄すれば内部のデータは消えてしまいます。そのためにVolumeなどを設定しデータの永続化を行いますが、litespeedはどこを永続化すればよいのかいまだにわからず・・・<br>今回行った設定も、コンテナを破棄したときに一緒に消えてしまうのです。<br>もうしばらく調べて、わからなかったらnginx続投かな・・・</p>



<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=monodon-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=4798060992&amp;linkId=768c617da9f180169a6702b1ce6d0354" frameborder="0"></iframe>
<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=monodon-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=4802611846&amp;linkId=ddcd997500705d738b3be6d885ce2a09" frameborder="0">
<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&#038;bc1=000000&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=monodon-22&#038;language=ja_JP&#038;o=9&#038;p=8&#038;l=as4&#038;m=amazon&#038;f=ifr&#038;ref=as_ss_li_til&#038;asins=1492041211&#038;linkId=8c266310c300e30a16f7d926cac2b2ae"></iframe>
<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=monodon-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=4839967679&amp;linkId=5c311346d83d901fa6d422b45486e871" frameborder="0"></iframe>



<p></p>
<p>投稿 <a href="https://sheltie-garage.xyz/2020/03/docker%e3%81%a7litespeed-web%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e6%a7%8b%e7%af%89%e3%81%97%e3%81%a6laravel%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/">DockerでLiteSpeed Webサーバを構築してLaravelを実行する</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ComposerでNoSslExceptionが発生したときの対応方法</title>
		<link>https://sheltie-garage.xyz/2019/10/composer%e3%81%a7nosslexception%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%97%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%bf%9c%e6%96%b9%e6%b3%95/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Thu, 17 Oct 2019 12:28:16 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=1646</guid>

					<description><![CDATA[<p>Composer updateを行ったときに以下のようなエラーが発生！ 原因はphpのアップデート作業でした phpはwindows環境で実行しています。phpのアップデートのため、一度phpディレクトリの中をすべて削除 [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/10/composer%e3%81%a7nosslexception%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%97%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%bf%9c%e6%96%b9%e6%b3%95/">ComposerでNoSslExceptionが発生したときの対応方法</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>Composer updateを行ったときに以下のようなエラーが発生！</p>



<pre class="crayon-plain-tag">[Composer\Exception\NoSslException]                                           
  The openssl extension is required for SSL/TLS protection but is not available. 
If you can not enable the openssl extension, you can disable this error, 
at your own risk, by setting the 'disable-tls' option to true.</pre>



<h2 class="wp-block-heading">原因はphpのアップデート作業でした</h2>



<p>phpはwindows環境で実行しています。<br>phpのアップデートのため、一度phpディレクトリの中をすべて削除し、新しいバージョンを上書きしました。<br>その際「php.ini」も消してしまい、結果としてopensslのエクステンションも無効になってしまっていました。</p>



<h2 class="wp-block-heading">OpenSSLの有効化</h2>



<p>php.iniを以下の通り編集しました</p>



<pre class="crayon-plain-tag">; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = &quot;./&quot;
; On windows:
extension_dir = &quot;ext&quot;　&larr;この行のコメントを外し、有効化</pre>



<pre class="crayon-plain-tag">;extension=bz2
・・・省略・・・
;extension=odbc
extension=openssl &larr;この行のコメントを外して有効化</pre>



<h2 class="wp-block-heading">以上</h2>



<p>以上の設定でComposerが動くようになりました。</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/10/composer%e3%81%a7nosslexception%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%97%e3%81%9f%e3%81%a8%e3%81%8d%e3%81%ae%e5%af%be%e5%bf%9c%e6%96%b9%e6%b3%95/">ComposerでNoSslExceptionが発生したときの対応方法</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHPアプリ高負荷の原因は？</title>
		<link>https://sheltie-garage.xyz/2019/06/php%e3%82%a2%e3%83%97%e3%83%aa%e9%ab%98%e8%b2%a0%e8%8d%b7%e3%81%ae%e5%8e%9f%e5%9b%a0%e3%81%af%ef%bc%9f/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 23 Jun 2019 11:55:10 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=1296</guid>

					<description><![CDATA[<p>本番運用しているシステムでずっと「PHP Laravelで作成したアプリの負荷が高い」という問題に悩まされていた。ここ最近意外、かつ簡単な方法で解決できたのでメモしておく。 プログラム改修やサーバ増強でアプローチしていた [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/06/php%e3%82%a2%e3%83%97%e3%83%aa%e9%ab%98%e8%b2%a0%e8%8d%b7%e3%81%ae%e5%8e%9f%e5%9b%a0%e3%81%af%ef%bc%9f/">PHPアプリ高負荷の原因は？</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>本番運用しているシステムでずっと「PHP Laravelで作成したアプリの負荷が高い」という問題に悩まされていた。<br>ここ最近意外、かつ簡単な方法で解決できたのでメモしておく。</p>



<h3 class="wp-block-heading">プログラム改修やサーバ増強でアプローチしていたが</h3>



<p>PHPアプリの負荷を下げつ方法として、プログラム改修を主に行っていた。<br>作られたプログラムで効率的にキャッシュを利用していなかったり、場合によっては数千レコード単位で結果を返し、それを配列でぐるぐるしているようなプログラムがあったからだ。<br>このあたりのプログラムを見直して、若干負荷を下げることはできた。</p>



<h3 class="wp-block-heading">nginx, php-fpmの設定も見直す</h3>



<p>nginxやphp-fpmの設定に関しても、以下の情報をもとチューニングを行った。<br>が、ミドルウェアのチューニングでは、それほど大きな効果が出なかった気がする。<br>チューニング方法が悪かったのか、もしくはこれらのミドルウェアのデフォルト値が割と優秀なのかも。<br>参考：<br> <a href="https://qiita.com/qiita_masaharu/items/29ec160c4e830c138132">https://qiita.com/qiita_masaharu/items/29ec160c4e830c138132</a> </p>



<p>一応、上記の対応で以前よりも負荷を抑えることが出来、安心していました。</p>



<h3 class="wp-block-heading">再び発生した高負荷問題</h3>



<p>新規で作成したLaravelアプリで再び高負荷問題が発生。<br>こちらもキャッシュ利用の見直しや、コードの最適化である程度負荷を下げることができた。<br>だが、それでも負荷が完全に下がり切らず、アクセス集中の時間帯はひやひやするレベルで負荷がかかっていた。</p>



<h3 class="wp-block-heading">同僚の気づきと原因判明</h3>



<p>ある日、フロントエンドに強い同僚が一言「対応します！」と言って何かを行ったところ、</p>



<p class="has-text-color has-medium-font-size has-vivid-red-color"> 負荷がぱったりと収まりました </p>



<p>いったい何を行ったのか聞いたところ</p>



<p class="has-text-color has-large-font-size has-vivid-red-color">xdebugのモジュールを削除しました</p>



<p>とのこと。<br>どうやら本番環境にもx-debugが入っており、これがかなりの負荷をかけていた模様。<br>x-debug削除後は今までの負荷が嘘のようで、アクセス集中の時間帯でも安定して稼働するようになりました。<br><br>ちなみに、なんでx-debugが高負荷の原因になっているのか突き止めることができたのか理由を聞いたところ</p>



<p class="has-text-color has-medium-font-size has-vivid-red-color">負荷対策を行ったプログラムをリリースしたのに、全く負荷が下がらないため、プログラム以外の部分に問題があることが分かった。</p>



<p>とのこと。<br>うーん、素晴らしい・・・<br><br>XDebug負荷の似たような事例として、以下のようなケースもある様です。<br> <a href="https://www.marineroad.com/staff-blog/14210.html">https://www.marineroad.com/staff-blog/14210.html</a> </p>



<h3 class="wp-block-heading">yumに頼りすぎた弊害か・・・</h3>



<p>環境構築時、yumで「とりあえずphp関連のもの入れてしまえ！」の勢いで構築したので、それ以降全く環境の見直しがかかっていなかった模様。<br>yumでの環境構築は便利だけど、何がインストールされるのか、ちゃんと把握していないとダメですね。<br>それ以前に、インフラ周りに強い人間が全くいないのも問題ですが・・・<br>アプリばっかりじゃなく、インフラ周りも勉強しないといけないですな。</p>



<p>カバー画像<br><a href="https://pixabay.com/ja/users/Mylene2401-10328767/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4151379">Mylene2401</a>による<a href="https://pixabay.com/ja/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4151379">Pixabay</a>からの画像</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/06/php%e3%82%a2%e3%83%97%e3%83%aa%e9%ab%98%e8%b2%a0%e8%8d%b7%e3%81%ae%e5%8e%9f%e5%9b%a0%e3%81%af%ef%bc%9f/">PHPアプリ高負荷の原因は？</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>KindleUnlimitedSearchをバージョンアップしました</title>
		<link>https://sheltie-garage.xyz/2019/01/kindleunlimitedsearch%e3%82%92%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%a2%e3%83%83%e3%83%97%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 27 Jan 2019 12:13:15 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=872</guid>

					<description><![CDATA[<p>KindleUnlimited専用検索アプリ「KindleUnlimitedSearch」をバージョンアップしました 主な改修内容は アダルト除外フラグの追加 レイアウト修正 となります これでPCで見てもある程度耐えら [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/01/kindleunlimitedsearch%e3%82%92%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%a2%e3%83%83%e3%83%97%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/">KindleUnlimitedSearchをバージョンアップしました</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p>KindleUnlimited専用検索アプリ「KindleUnlimitedSearch」をバージョンアップしました</p>
<p>主な改修内容は</p>
<ul>
<li>アダルト除外フラグの追加</li>
<li>レイアウト修正</li>
</ul>
<p>となります</p>
<p>これでPCで見てもある程度耐えられるはず。</p>
<p>ちなみにアダルト除外フラグですが、Amazon側でのアダルト判定が甘い?ようで、<br />
これってアダルトだよね？　と思われる本に対して、アダルトフラグが立っていなかったりします。<br />
要約すると、アダルト除外にしていても、アダルト商品が表示される可能性があるのでお気を付けください。</p>
<p>ちなみに、このアプリはAmazon内でKindleUnlimited対象の商品が探し辛いため作成したものですが、最近やっと対象書籍を一覧で見れるリンクを見つけました。<br />
<a href="https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2.png"><img loading="lazy" decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2-1024x454.png" alt="" width="640" height="284" class="alignnone size-large wp-image-873" srcset="https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2-1024x454.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2-300x133.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2-768x341.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2019/01/Image-2.png 1233w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<p>ここにありましたね・・・<br />
アプリの表示結果も、ここと同じ内容になります</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2019/01/kindleunlimitedsearch%e3%82%92%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%e3%82%a2%e3%83%83%e3%83%97%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/">KindleUnlimitedSearchをバージョンアップしました</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel + CoreUI設定済み　ボイラーテンプレートを使う</title>
		<link>https://sheltie-garage.xyz/2018/10/laravel-coreui%e8%a8%ad%e5%ae%9a%e6%b8%88%e3%81%bf%e3%80%80%e3%83%9c%e3%82%a4%e3%83%a9%e3%83%bc%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%92%e4%bd%bf%e3%81%86/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Thu, 18 Oct 2018 22:23:10 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=657</guid>

					<description><![CDATA[<p>LaravelにCoreUIを導入しようと思い、いろいろ調べてみたのですが方法が分からなかったため、公開されているボイラーテンプレートを使うことにしました GitHubにいろいろな方のボイラーテンプレートが準備されている [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel-coreui%e8%a8%ad%e5%ae%9a%e6%b8%88%e3%81%bf%e3%80%80%e3%83%9c%e3%82%a4%e3%83%a9%e3%83%bc%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%92%e4%bd%bf%e3%81%86/">Laravel + CoreUI設定済み　ボイラーテンプレートを使う</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p>LaravelにCoreUIを導入しようと思い、いろいろ調べてみたのですが方法が分からなかったため、公開されているボイラーテンプレートを使うことにしました</p>
<p>GitHubにいろいろな方のボイラーテンプレートが準備されているのですが、最新かつシンプルということで、以下のボイラーテンプレートを使用しました<br />
<a href="https://github.com/adenvt/laravel-coreui-vue">https://github.com/adenvt/laravel-coreui-vue</a></p>
<p>インストール方法はGitHubのReadMeに記載があるので、その通りに作成すればOK</p>
<p>プロジェクト作成後に作成したプロジェクトにアクセスすれば、CoreUIが適用済みの画面が表示されます</p>
<p><a href="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1.png"><img loading="lazy" decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1-1024x572.png" alt="" width="640" height="358" class="alignnone size-large wp-image-658" srcset="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1-1024x572.png 1024w, https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1-300x168.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1-768x429.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1-1.png 1422w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<h2>終わりに</h2>
<p>これできれいなUIが設定されたプロジェクトが簡単に作成できますね<br />
まずは内部がどうなっているのか解析していきます</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel-coreui%e8%a8%ad%e5%ae%9a%e6%b8%88%e3%81%bf%e3%80%80%e3%83%9c%e3%82%a4%e3%83%a9%e3%83%bc%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%92%e4%bd%bf%e3%81%86/">Laravel + CoreUI設定済み　ボイラーテンプレートを使う</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel + Vue + Vue-Router + Bootstrup-Vueの環境を作る</title>
		<link>https://sheltie-garage.xyz/2018/10/laravel-vue-vue-router-bootstrup-vue%e3%81%ae%e7%92%b0%e5%a2%83%e3%82%92%e4%bd%9c%e3%82%8b/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Wed, 10 Oct 2018 22:22:26 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=620</guid>

					<description><![CDATA[<p>タイトルが長い・・・ タイトルの環境でSPAを作ろうとして、意外とはまったのでメモ 多分、メモしながら作業しないと、2回目作るときも同じ失敗をしそう・・・ Laravelプロジェクト作成 これはいつも通りの手順で・・・  [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel-vue-vue-router-bootstrup-vue%e3%81%ae%e7%92%b0%e5%a2%83%e3%82%92%e4%bd%9c%e3%82%8b/">Laravel + Vue + Vue-Router + Bootstrup-Vueの環境を作る</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p>タイトルが長い・・・</p>
<p>タイトルの環境でSPAを作ろうとして、意外とはまったのでメモ<br />
多分、メモしながら作業しないと、2回目作るときも同じ失敗をしそう・・・</p>
<h2>Laravelプロジェクト作成</h2>
<p>これはいつも通りの手順で・・・</p>
<p></p><pre class="crayon-plain-tag">$ laravel new VueEnv</pre><p></p>
<h2>Bootstrup-Vue</h2>
<p>ここがはまったポイントのひとつ目<br />
すでにLaravelに入っていると思ったけど、npmで新規インストールする必要があった</p>
<p></p><pre class="crayon-plain-tag">$ cd VueEnv
$ npm i bootstrap-vue</pre><p></p>
<h2>Vue-Router</h2>
<p>こちらもnpmでインストールできます</p>
<p></p><pre class="crayon-plain-tag">$ npm install vue-router</pre><p></p>
<p>以上でフレームワークのインストールは完了です。</p>
<h2>Laravelアプリの変更</h2>
<p><strong>\VueEnv\resources\js\app.jsapp.js</strong><br />
Bootstrup-vueとVue-Routerの公式サイトにあるサンプルコードを貼り付ける。<br />
サンプルコードはそれぞれ<br />
Vue-Router<br />
<a href="https://router.vuejs.org/ja/installation.html">https://router.vuejs.org/ja/installation.html</a><br />
<a href="https://router.vuejs.org/ja/guide/#javascript">https://router.vuejs.org/ja/guide/#javascript</a></p>
<p>Bootstrup-Vue<br />
<a href="https://bootstrap-vue.js.org/docs/">https://bootstrap-vue.js.org/docs/</a><br />
を、使いました。<br />
全体像はこんな感じになります。</p>
<p></p><pre class="crayon-plain-tag">// Vue-Routerの設定
import Vue from 'vue'
import VueRouter from 'vue-router'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(VueRouter);
Vue.use(BootstrapVue);

// 0. モジュールシステムを使っている場合 (例: vue-cli 経由で)、Vue と VueRouter をインポートし、`Vue.use(VueRouter)` を呼び出します。

// 1. ルートコンポーネントを定義します
// 他のファイルからインポートすることもできます
const Foo = { template: '&amp;lt;div&amp;gt;foo&amp;lt;/div&amp;gt;' }
const Bar = { template: '&amp;lt;div&amp;gt;bar&amp;lt;/div&amp;gt;' }

// 2. ルートをいくつか定義します
// 各ルートは 1 つのコンポーネントとマッピングされる必要があります。
// このコンポーネントは実際の `Vue.extend()`、
// またはコンポーネントオプションのオブジェクトでも構いません。
// ネストされたルートに関しては後で説明します
const routes = [
  { path: '/foo', component: Foo },
  { path: '/bar', component: Bar }
]

// 3. ルーターインスタンスを作成して、ルートオプションを渡します
// 追加のオプションをここで指定できますが、
// この例ではシンプルにしましょう
const router = new VueRouter({
  routes // `routes: routes` の短縮表記
})

// 4. root となるインスタンスを作成してマウントします
// アプリケーション全体がルーターを認知できるように、
// ルーターをインジェクトすることを忘れないでください。
const app = new Vue({
  router
}).$mount('#app')

// これで開始です!</pre><p></p>
<h2>Laravelコントローラなどの作成</h2>
<p>Laravelコントローラを作成して、とりあえず動くようにします。<br />
この手順については、以前の記事「<a href="https://sheltie-garage.xyz/2018/09/laravel%E3%81%A7spa%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B/">LARAVELでSPAアプリケーションページを作成する</a>」と同様になるため、省略します。<br />
RestfulAPI用のコントローラと、エントリポイントとなるView「app.blade.php」を作成します。</p>
<h2>app.blade.phpの編集</h2>
<p>コントローラとビューが出来たら、app.blade.phpの内容をこれまたそれぞれの公式ページをもとに、内容を変更してみます。<br />
テンプレートの中身は、「<a href="https://bootstrap-vue.js.org/docs/reference/starter-templates/">Starter Templates</a>」をベースにカスタマイズしてみます。<br />
全体像はこんな感じ</p>
<p></p><pre class="crayon-plain-tag">&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;en&quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;!-- Required meta tags --&amp;gt;
    &amp;lt;meta charset=&quot;utf-8&quot;&amp;gt;
    &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, shrink-to-fit=no&quot;&amp;gt;
    &amp;lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&amp;gt;

    &amp;lt;title&amp;gt;My first Bootstrap-Vue app&amp;lt;/title&amp;gt;
    &amp;lt;link href=&quot;{{asset('css/app.css')}}&quot; rel=&quot;stylesheet&quot;&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;!-- Our application root element --&amp;gt;
    &amp;lt;div id=&quot;app&quot;&amp;gt;
      &amp;lt;b-container&amp;gt;
        &amp;lt;b-jumbotron header=&quot;Bootstrap Vue&quot;
                     lead=&quot;Bootstrap 4 Components for Vue.js 2&quot;
        &amp;gt;
          &amp;lt;p&amp;gt;For more information visit our website&amp;lt;/p&amp;gt;
          &amp;lt;b-btn variant=&quot;primary&quot; href=&quot;https://bootstrap-vue.js.org/&quot;&amp;gt;More Info&amp;lt;/b-btn&amp;gt;
        &amp;lt;/b-jumbotron&amp;gt;

      &amp;lt;/b-container&amp;gt;

      &amp;lt;b-container&amp;gt;
        &amp;lt;router-link to=&quot;/foo&quot;&amp;gt;Go to Foo&amp;lt;/router-link&amp;gt;
        &amp;lt;router-link to=&quot;/bar&quot;&amp;gt;Go to Bar&amp;lt;/router-link&amp;gt;

        &amp;lt;router-view&amp;gt;&amp;lt;/router-view&amp;gt;
      &amp;lt;/b-container&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;script src=&quot;{{asset('js/app.js')}}&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;</pre><p></p>
<h2>ビルドして動作確認</h2>
<p>以上で、Laravel + Vue + Vue-Router + Bootstrup-Vueの環境ができたはずです。<br />
WebPackにてリソースをビルド後、動作を確認してみましょう。<br />
プロジェクトディレクトリで、以下のコマンドでビルドします</p>
<p></p><pre class="crayon-plain-tag">npm run watch</pre><p></p>
<p><strong>メモ</strong><br />
初回のnpm run watch実行時に以下のエラーが発生した</p>
<p></p><pre class="crayon-plain-tag">npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Sheltie\AppData\Roaming\npm-cache\_logs\2018-10-10T22_08_22_834Z-debug.log</pre><p></p>
<p>npm installでパッケージをインストールしたら直った</p>
<p></p><pre class="crayon-plain-tag">$ npm install</pre><p></p>
<h2>動作確認</h2>
<p>実際に動きを確認します。以下のURLにアクセス<br />
http://vue-env.test/ <img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-1.png" alt="enter image description here" /></p>
<p>「Go to Foo」「Go to Bar」のリンクをそれぞれクリックすると、URLと画面表記が変わることが確認できるかと思います。 <img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-2.png" alt="enter image description here" /> <img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-3.png" alt="enter image description here" /></p>
<h2>終わりに</h2>
<p>これでLaravel + Vue + Vue-Router + Bootstrup-Vueの環境ができました。<br />
今回取り入れたかった要素はすべてそろったので、やっとこさアプリ開発に取り組むことができそうです。</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel-vue-vue-router-bootstrup-vue%e3%81%ae%e7%92%b0%e5%a2%83%e3%82%92%e4%bd%9c%e3%82%8b/">Laravel + Vue + Vue-Router + Bootstrup-Vueの環境を作る</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel用AmazonAPIモジュール</title>
		<link>https://sheltie-garage.xyz/2018/10/laravel%e7%94%a8amazonapi%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab/</link>
					<comments>https://sheltie-garage.xyz/2018/10/laravel%e7%94%a8amazonapi%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab/#comments</comments>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Tue, 02 Oct 2018 21:46:07 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=598</guid>

					<description><![CDATA[<p>Laravel + SPAの勉強を進めてます。 手始めに「Kindle Unlimited」対象の本を検索できるようなサービスを作成してみようとしています。 経緯 最近Kindle Unlimitedに加入してみました。 [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel%e7%94%a8amazonapi%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab/">Laravel用AmazonAPIモジュール</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p>Laravel + SPAの勉強を進めてます。<br />
手始めに「Kindle Unlimited」対象の本を検索できるようなサービスを作成してみようとしています。</p>
<h2>経緯</h2>
<p>最近Kindle Unlimitedに加入してみました。<br />
が、Kindle Unlimitedの本って、Amazon公式サイトだとなんか検索しにくいと感じていまして、それなら、自分で、自分が使いやすい検索画面を作ってしまおうということで調査を開始しました。</p>
<h2>Laravel用 AmazonAPIモジュールのインストール</h2>
<p>探せばあるものですね。<br />
laravel用のAmazon APIモジュールがあったので、プロジェクトに組み込みます。<br />
<a href="https://github.com/kawax/laravel-amazon-product-api">https://github.com/kawax/laravel-amazon-product-api</a></p>
<p>コマンドは以下の通り。作成したLaravelプロジェクトのフォルダに移動して実行します。</p>
<p></p><pre class="crayon-plain-tag">composer require revolution/laravel-amazon-product-api
php artisan vendor:publish --provider=&quot;Revolution\Amazon\ProductAdvertising\Providers\AmazonProductServiceProvider&quot;</pre><p></p>
<h2>.envファイルの編集</h2>
<p>Laravelの.envファイルにAPI用の設定を追加。<br />
COUNTRYは日本の場合、co.jpを指定することになります。</p>
<p></p><pre class="crayon-plain-tag">AMAZON_API_KEY=
AMAZON_API_SECRET_KEY=
AMAZON_ASSOCIATE_TAG=
AMAZON_COUNTRY=co.jp</pre><p></p>
<h2>とりあえず動かす</h2>
<p>RESTApiコントローラを作成し、アマゾンAPIを読みだしてみます。</p>
<p><strong>\routes\api.php</strong></p>
<p></p><pre class="crayon-plain-tag">Route::resource('search', 'KindleSearchApiController');</pre><p></p>
<p><strong>\app\Http\Controllers\KindleSearchApiController.php</strong></p>
<p></p><pre class="crayon-plain-tag">use AmazonProduct; // 追加

public function index()
{
    //
    $response = AmazonProduct::search('All', 'amazon' , 1);

    return $response;
}</pre><p></p>
<h2>URLにアクセスしてみる</h2>
<p>とりあえずレスポンスが取得できます</p>
<p><strong>http://kus.test/api/search</strong><br />
<img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-9.png" alt="enter image description here" /></p>
<h2>Kindle Unlimitedの商品に絞ってみる</h2>
<p>AmazonAPIでは、Node(分類のようなもの？)で商品を絞ることができます。<br />
以下の記事で、AmazonAPIのnode一覧が確認できるので、Kindle Unlimitedのノード番号「4486610051」を得ることができます。<br />
<a href="https://qiita.com/kobake@github/items/88001f62983211027f63">https://qiita.com/kobake@github/items/88001f62983211027f63</a></p>
<p><strong>\app\Http\Controllers\KindleSearchApiController.php</strong></p>
<p></p><pre class="crayon-plain-tag">public function index() {
    // 
    // $response = AmazonProduct::search('All', 'amazon' , 1); 
    $response = AmazonProduct::browse('4486610051');

    return $response;
}</pre><p></p>
<p><img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/10/Image-10.png" alt="enter image description here" /></p>
<h2>終わりに</h2>
<p>ひとまずAmazonAPIを利用してKindle Unlimitedに絞った商品を取得することができました。<br />
Vue.jsと組み合わせれば、読み放題に特化した検索サイトが作れそうですね。</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/10/laravel%e7%94%a8amazonapi%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab/">Laravel用AmazonAPIモジュール</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sheltie-garage.xyz/2018/10/laravel%e7%94%a8amazonapi%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>LaravelでSPAアプリケーションページを作成する</title>
		<link>https://sheltie-garage.xyz/2018/09/laravel%e3%81%a7spa%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b/</link>
					<comments>https://sheltie-garage.xyz/2018/09/laravel%e3%81%a7spa%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b/#comments</comments>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Thu, 27 Sep 2018 23:07:10 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=569</guid>

					<description><![CDATA[<p>SPAとは SinglePageApplicationの略で、画面遷移が発生せず、javaScriptなどを駆使して画面の内容を書き換えて動作するアプリケーションのことみたいです。 LaravelにはSPAを作成するため [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/09/laravel%e3%81%a7spa%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b/">LaravelでSPAアプリケーションページを作成する</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<h1>SPAとは</h1>
<p>SinglePageApplicationの略で、画面遷移が発生せず、javaScriptなどを駆使して画面の内容を書き換えて動作するアプリケーションのことみたいです。<br />
LaravelにはSPAを作成するための一式が組み込まれているようなので、簡単なSPAを作成してみたいと思います。</p>
<p>参考にしたのは、以下の記事になります。<br />
&lt;<a href="https://qiita.com/acro5piano/items/f33381fc60408abe9865">https://qiita.com/acro5piano/items/f33381fc60408abe9865</a>></p>
<h2>Laravelプロジェクト作成</h2>
<p>まずはLaravelプロジェクトを作成します。<br />
いつものコマンドで作成</p>
<p></p><pre class="crayon-plain-tag">laravel new SPA</pre><p></p>
<h2>laradockの設定</h2>
<p>開発環境のlaradockに先ほど作成したSPAプロジェクトを追加します。<br />
nginxの設定を新規追加します</p>
<p></p><pre class="crayon-plain-tag">既存ファイルをコピーして作成
laradock\nginx\sites\spa.conf
中身の下記の部分を編集
server_name spa.test;
root /var/www/spa/public;
index index.php index.html index.htm;

以下のファイルを編集
C:\Windows\System32\drivers\etc\hosts
設定を追加
127.0.0.1 spa.test</pre><p></p>
<p>laradockを起動し、とりあえずサイトにアクセスできるか確認します</p>
<p></p><pre class="crayon-plain-tag">docker-compose.exe up -d nginx mysql</pre><p></p>
<p>サイトにアクセス<br />
http://spa.test/</p>
<p>いつもの画面が出てくれば、とりあえずOK <img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-6.png" alt="enter image description here" /></p>
<h1>RestAPIの作成</h1>
<h2>コントローラの作成</h2>
<p>artisanコマンドを利用してRest用コントローラを作成します。</p>
<p></p><pre class="crayon-plain-tag">php artisan make:controller SPAController --resource</pre><p></p>
<p>コントローラを編集します。<br />
とりあえず、メソッド名を返却する処理を追加します。</p>
<p></p><pre class="crayon-plain-tag">\SPA\app\Http\Controllers\SPAController.php

/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    //
    return ['data' =&amp;gt; 'index'];
}</pre><p></p>
<h2>ルートの設定</h2>
<p>Rest用のルートを追加します。</p>
<p></p><pre class="crayon-plain-tag">\SPA\routes\api.php

Route::resource('spa', 'SPAController');</pre><p></p>
<p>ここまで設定していかにアクセスすると、簡単なJsonが帰ってくることが確認できると思います。 http://spa.test/api/spa</p>
<h1>SPAのベースページの作成</h1>
<h2>ルートの設定</h2>
<p>/api/* 以外のURLにアクセスが来た時に応答するルートを設定する</p>
<p></p><pre class="crayon-plain-tag">\SPA\routes\web.php

Route::get('/{any}', function () {
    return view('app');
})-&amp;gt;where('any', '.*');</pre><p></p>
<p>これで、api以外にアクセスが来たときは、app.blade.phpが応答されるようになる。</p>
<h2>クライアントサイドのルーティングライブラリ取得</h2>
<p>vue-routerを使用するため、プロジェクトフォルダ内にあるpackage.jsonを編集</p>
<p></p><pre class="crayon-plain-tag">&quot;vue-router&quot;: &quot;^3.0.0&quot;</pre><p></p>
<p>npmコマンドでインストール</p>
<p></p><pre class="crayon-plain-tag">npm install</pre><p></p>
<p>WebPack起動</p>
<p></p><pre class="crayon-plain-tag">npm run watch</pre><p></p>
<p>が、起動したところ、いろいろエラーが出たので対処<br />
エラー：Module build failed: Error: Cannot find module &#8216;babel-core&#8217;<br />
対処：<a href="https://github.com/babel/gulp-babel/issues/124">https://github.com/babel/gulp-babel/issues/124</a> の記事にあった、以下のコマンドを実行</p>
<p></p><pre class="crayon-plain-tag">npm install --save-dev babel-core babel-preset-env</pre><p></p>
<p>エラー: Error: Can&#8217;t resolve &#8216;css-loader&#8217;, Module not found: Error: Can&#8217;t resolve &#8216;postcss-loader&#8217;<br />
対処：<a href="https://github.com/webpack/webpack/issues/1470">https://github.com/webpack/webpack/issues/1470</a>の記事の以下のコマンドを実施</p>
<p></p><pre class="crayon-plain-tag">npm install --save-dev css-loader
npm install --save-dev postcss-loader</pre><p></p>
<p>エラー: Module build failed: Error: Cannot find module &#8216;node-sass&#8217;<br />
対処：過去のコマンドを利用してインストール</p>
<p></p><pre class="crayon-plain-tag">npm install --save-dev node-sass</pre><p></p>
<p>以上でWebpackのビルドがうまくいくようになりました</p>
<h2>Ajax通信ライブラリ「axios」</h2>
<p>axiosを利用し、ajax通信を行います。</p>
<p></p><pre class="crayon-plain-tag">\SPA\resources\js\bootstrap.js

window.axios = require('axios')

window.axios.defaults.headers.common = {
    'X-CSRF-TOKEN': window.Laravel.csrfToken,
    'X-Requested-With': 'XMLHttpRequest'
}

Vue.prototype.$http = window.axios</pre><p></p>
<p>メインのjsファイルに処理を追加します。</p>
<p></p><pre class="crayon-plain-tag">\SPA\resources\js\app.js

window.Vue = require('vue');

import Vue from 'vue'
import VueRouter from 'vue-router'

require('./bootstrap')

Vue.use(VueRouter)

Vue.component('navbar', require('./components/Layouts/Navbar.vue'))

const router = new VueRouter({
    mode: 'history',
    routes: [
        { path: '/', component: require('./components/Articles/Index.vue') },
        { path: '/about', component: require('./components/About.vue') },
    ]
})

const app = new Vue({
    router,
    el: '#app'
})</pre><p></p>
<p>※<code>npm run watch</code> を起動していると、jsの編集に応じて自動ビルドが動く。今回は、まだ作成していない <code>Index.vue</code> <code>About.vue</code> を指定しているためエラーが表示されるが、気にしない。</p>
<h2>Viewを作成</h2>
<p>Laravelが返却する唯一のビューとなる「app.blade.php」を作成します。</p>
<p></p><pre class="crayon-plain-tag">\SPA\resources\views\app.blade.php    

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang=&quot;{{ config('app.locale') }}&quot;&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;meta charset=&quot;utf-8&quot;&amp;gt;
        &amp;lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&amp;gt;
        &amp;lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&amp;gt;

        &amp;lt;title&amp;gt;Laravel&amp;lt;/title&amp;gt;

        &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;{{ mix('css/app.css') }}&quot;&amp;gt;&amp;lt;/script&amp;gt;

        &amp;lt;script&amp;gt;
            window.Laravel = {
                csrfToken: &quot;{{ csrf_token() }}&quot;
            };
        &amp;lt;/script&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;div id=&quot;app&quot;&amp;gt;
            &amp;lt;navbar&amp;gt;&amp;lt;/navbar&amp;gt;
            &amp;lt;div class=&quot;container&quot;&amp;gt;
                &amp;lt;router-view&amp;gt;&amp;lt;/router-view&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;script src=&quot;{{ mix('js/app.js') }}&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/html&amp;gt;</pre><p></p>
<h2>Vue Component作成</h2>
<p>以下の2つのコンポーネントをそれぞれ作成します。</p>
<p></p><pre class="crayon-plain-tag">\SPA\resources\js\components\Layouts\Navbar.vue

&amp;lt;template&amp;gt;
    &amp;lt;nav class=&quot;navbar navbar-default&quot;&amp;gt;
        &amp;lt;li&amp;gt;
            &amp;lt;router-link  to=&quot;/about&quot;&amp;gt;About&amp;lt;/router-link&amp;gt;
        &amp;lt;/li&amp;gt;
    &amp;lt;/nav&amp;gt;
&amp;lt;/template&amp;gt;


\SPA\resources\js\components\About.vue

&amp;lt;template&amp;gt;
    &amp;lt;div&amp;gt;
        This page describe who we are.
    &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;</pre><p></p>
<h2>ajax通信を行う</h2>
<p>VueからLaravelへajax通信を行います。<br />
apiにアクセスしてメソッド名を取得するだけの処理となります。</p>
<p></p><pre class="crayon-plain-tag">\SPA\resources\js\components\Articles\Index.vue

&amp;lt;template&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;
            {{ name }}
        &amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
    export default {
        created() {
            this.getApiName()
        },
        data() {
            return {
                name: ''
            }
        },
        methods: {
            getApiName() {
                this.$http.get('/api/spa')
                .then(res =&amp;gt;  {
                    this.name = res.data.data
                })
            }
        }
    }
&amp;lt;/script&amp;gt;</pre><p></p>
<h1>実行してみる</h1>
<p>以上で、LaravelとVueを使用したSPAが完成したはずなので、サイトにアクセスしてみます。<br />
http://spa.test/<br />
<img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-7.png" alt="enter image description here" /></p>
<p>http://spa.test/about<br />
<img decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-8.png" alt="enter image description here" /></p>
<p>かなり不格好ではありますが、ひとまずVue + axios でSPAのひな型を作成することができました。</p>
<h1>終わりに</h1>
<p>今回はLaravel + VueでSPAのひな型を作成してみました。<br />
初めて使う技術ばかりなので、いろいろ躓きそうですが、今後はこれをもとに小さなWebアプリを作っていけたらなぁという感じです。<br />
javaScriptもきちんと勉強しないと、すでに構文が意味不明ですねぇ・・・ (´・ω・｀)</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/09/laravel%e3%81%a7spa%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b/">LaravelでSPAアプリケーションページを作成する</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sheltie-garage.xyz/2018/09/laravel%e3%81%a7spa%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>LaradockのDBアクセス設定まとめ</title>
		<link>https://sheltie-garage.xyz/2018/09/laradock%e3%81%aedb%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e8%a8%ad%e5%ae%9a%e3%81%be%e3%81%a8%e3%82%81/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Sun, 02 Sep 2018 12:19:35 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術系]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=469</guid>

					<description><![CDATA[<p>Laradockで環境を構築したのはいいものの、Laravelアプリ、「php artisanコマンド」「ホストマシンからのMySQL Workbench」でそれぞれのDB設定のまとめです。 ・Laradockの設定確認 [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/09/laradock%e3%81%aedb%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e8%a8%ad%e5%ae%9a%e3%81%be%e3%81%a8%e3%82%81/">LaradockのDBアクセス設定まとめ</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[
<p>Laradockで環境を構築したのはいいものの、Laravelアプリ、「php artisanコマンド」「ホストマシンからのMySQL Workbench」でそれぞれのDB設定のまとめです。</p>



<p>・Laradockの設定確認</p>



<p>自分の環境では以下の設定になっています</p>



<p>laradockの.env設定</p>



<pre class="crayon-plain-tag">### MYSQL #################################################

MYSQL_VERSION=latest
MYSQL_DATABASE=default
MYSQL_USER=default
MYSQL_PASSWORD=secret
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=root
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d</pre>



<p>上記の設定より、ユーザー:default, パスワード:secretとなります</p>



<h2 class="wp-block-heading">Laravelアプリの設定</h2>



<p>Laravelの.env設定は以下の通り</p>



<pre class="crayon-plain-tag">DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret</pre>



<p>DB_HOSTには、docker-compose.xmlのサービス名を指定します</p>



<h2 class="wp-block-heading">MySQL Workbench</h2>



<p>ホストから、DockerコンテナのMysqlに接続する設定は以下の通り</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="879" height="585" src="https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-1.png" alt="" class="wp-image-470" srcset="https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-1.png 879w, https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-1-300x200.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-1-768x511.png 768w, https://sheltie-garage.xyz/wp-content/uploads/2018/09/Image-1-400x266.png 400w" sizes="auto, (max-width: 879px) 100vw, 879px" /><figcaption>ほかのタブはデフォルト設定です</figcaption></figure>



<h2 class="wp-block-heading">php artisan migrateコマンド</h2>



<p>dockerコマンドでコンテナ内に入る必要があります</p>



<pre class="crayon-plain-tag">GitBashから以下のコマンドを実行
$ winpty docker-compose exec workspace bash

その後、目的のプロジェクトフォルダ内でartisanコマンドを実行
root@9dbe7ec65ea8:/var/www# php artisan migrate</pre>



<p>Laradockは便利ですが、環境構築後はいろいろ戸惑ってしまいますね。</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/09/laradock%e3%81%aedb%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e8%a8%ad%e5%ae%9a%e3%81%be%e3%81%a8%e3%82%81/">LaradockのDBアクセス設定まとめ</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Windows10 Laradockでローカル開発環境につながらなくなったお話</title>
		<link>https://sheltie-garage.xyz/2018/08/windows10-laradock%e3%81%a7%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e3%81%ab%e3%81%a4%e3%81%aa%e3%81%8c%e3%82%89%e3%81%aa%e3%81%8f%e3%81%aa%e3%81%a3%e3%81%9f%e3%81%8a/</link>
		
		<dc:creator><![CDATA[sheltie]]></dc:creator>
		<pubDate>Mon, 20 Aug 2018 22:55:03 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://sheltie-garage.xyz/?p=457</guid>

					<description><![CDATA[<p>前回の記事でlaradockを使って開発環境を構築しましたが、何かのきっかけで接続不可になってしまいました。 google chromeを使用したときのエラー画面は以下の通りです。 エラーメッセージは「ERR_EMPTY [&#8230;]</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/08/windows10-laradock%e3%81%a7%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e3%81%ab%e3%81%a4%e3%81%aa%e3%81%8c%e3%82%89%e3%81%aa%e3%81%8f%e3%81%aa%e3%81%a3%e3%81%9f%e3%81%8a/">Windows10 Laradockでローカル開発環境につながらなくなったお話</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://sheltie-garage.xyz/2018/08/laravel%e3%81%ae%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e3%82%92docker%e3%81%a7%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b/">前回の記事</a>でlaradockを使って開発環境を構築しましたが、何かのきっかけで接続不可になってしまいました。<br />
google chromeを使用したときのエラー画面は以下の通りです。<br />
<a href="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-2.png"><img loading="lazy" decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-2.png" alt="" width="590" height="412" class="alignnone size-full wp-image-458" srcset="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-2.png 590w, https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-2-300x209.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-2-400x279.png 400w" sizes="auto, (max-width: 590px) 100vw, 590px" /></a></p>
<p>エラーメッセージは「ERR_EMPTY_RESPONSE」というもの。</p>
<p><strong>解決方法</strong><br />
以下のサイトを参考にしました。<br />
<a href="https://qiita.com/spiderx_jp/items/fa8d5ffe298759df9e06" rel="noopener" target="_blank">https://qiita.com/spiderx_jp/items/fa8d5ffe298759df9e06</a></p>
<p>自分の環境でもカスペルスキーを使用しており、何かの拍子にネットワーク設定を変更してしまったようです。<br />
カスペルスキーの設定画面で「プロテクション」>「ファイアーウォール」>「ネットワーク」の順に選択し、DockerNATのネットワークを「許可するネットワーク」に変更。<br />
<a href="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-3-1.png"><img loading="lazy" decoding="async" src="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-3-1.png" alt="" width="643" height="107" class="alignnone size-full wp-image-459" srcset="https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-3-1.png 643w, https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-3-1-300x50.png 300w, https://sheltie-garage.xyz/wp-content/uploads/2018/08/Image-3-1-400x67.png 400w" sizes="auto, (max-width: 643px) 100vw, 643px" /></a></p>
<p>これで無事にローカル環境に接続できるようになりました。</p>
<p>投稿 <a href="https://sheltie-garage.xyz/2018/08/windows10-laradock%e3%81%a7%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e3%81%ab%e3%81%a4%e3%81%aa%e3%81%8c%e3%82%89%e3%81%aa%e3%81%8f%e3%81%aa%e3%81%a3%e3%81%9f%e3%81%8a/">Windows10 Laradockでローカル開発環境につながらなくなったお話</a> は <a href="https://sheltie-garage.xyz">Sheltie&#039;s Garage</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
