純粋SPA VS バックエンドにSPA JSフレームワークを埋め込む

純粋SPAで大規模サービスの場合、初回起動時すべてのJS,CSSファイルを読み込むためパフォーマンスに影響が出る。

バックエンド埋め込み型SPAの場合、バックエンドのルーティングでサブドメインごとにSPAの起点ページを振り分けられるので読み込むファイルを分断できる????

Laravel5.4 と Vue2 のcomponentsの連携

環境:cloud9上にPHP7、laravel5.4をインストール。laravel内に設置したvueファイルの表示に関して。

vueファイル内にlaravelのdirectiveは混ぜられない(コンパイル時エラーが発生する)

 

 vueで作成したファイル内にlaravelのmiddlewareやproviderを通したデータを挿入したい場合、例えば…

 

  • 方法1

laravel側

Route::get('/user', function(){
  return Auth::user();
})->middleware('auth');

vue側

const app = new Vue({
  el: '#app',
  store,
  router: router,
  created() {
    axios.get('/user').then(response => {

      console.log(response);  

    })

  }
});

vueインスタンス生成時(created)にaxios経由でサーバーにリクエストを送り、laravel側で加工したデータを受け取る。

参考:

https://youtu.be/8aTfMHg3V1Q?list=PLXsbBbd36_uVjOFH_P25__XAyGsohXWlv&t=447

 

  • 方法2

同一ページ内にlaravel blade templateで作成したcomponentがある場合、vueファイル上で$('hoge').text()などで直接jsで加工済みの値を取得する。

 

参考:

https://youtu.be/8aTfMHg3V1Q?list=PLXsbBbd36_uVjOFH_P25__XAyGsohXWlv&t=802

Laravel 5.4 Laravel Mix error: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

cloud9上のubuntuのnodeのversionが古いため発生。

→ nvm install stable

・・・nodeをupdate

→ npm run dev

・・・正常に動作

Laravel5.4 + laravel/socialite google oauth issue

googleAPIにリクエストを投げた後、適切にcallbackURLを設定しているのにも関わらず下記のエラーが発生した時

 

"ClientException in RequestException.php line 107: Client error: `GET https://www.googleapis.com/plus/v1/people/me?prettyPrint=false` resulted in a `403 Forbidden` response:

{"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Access Not Configured. Google+ API (truncated...)"

 

googleAPIダッシュボードにてgoogle+apiを有効化する

http://itsolutionstuff.com/upload/google-click-google-api.png

 

http://itsolutionstuff.com/upload/google-enable-api.png

 

参考:

itsolutionstuff.com