純粋SPAで大規模サービスの場合、初回起動時すべてのJS,CSSファイルを読み込むためパフォーマンスに影響が出る。
バックエンド埋め込み型SPAの場合、バックエンドのルーティングでサブドメインごとにSPAの起点ページを振り分けられるので読み込むファイルを分断できる????
環境:cloud9上にPHP7、laravel5.4をインストール。laravel内に設置したvueファイルの表示に関して。
*vueファイル内にlaravelのdirectiveは混ぜられない(コンパイル時エラーが発生する)
vueで作成したファイル内にlaravelのmiddlewareやproviderを通したデータを挿入したい場合、例えば…
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
同一ページ内にlaravel blade templateで作成したcomponentがある場合、vueファイル上で$('hoge').text()などで直接jsで加工済みの値を取得する。
参考:
https://youtu.be/8aTfMHg3V1Q?list=PLXsbBbd36_uVjOFH_P25__XAyGsohXWlv&t=802
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を有効化する
参考:
php artisan migrate
→
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_emai l_unique`(`email`))
MySQLのencodingがutf8mb4の場合は4バイトのため、255 * 4 = 1,020 バイトとなり、767バイトを超えてしまうためエラーが発生
カラムのlimitを191に制限 191 * 4 = 764バイトとなり制限以内に抑える
この設定変更前は php artisan migrate:rollback 等々のコマンドでもエラーが発生
設定前に php artisan migrate でエラーデータベースを作っていた場合は手動でデータベースを削除した後に設定をし直す
Schema::defaultStringLength(191);
use Illuminate\Support\Facades\Schema;
参考:
php artisan make:migraiton create_xxx_table
入力時のエラー
include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to open stream: No such file or directory
一旦作ったmigrationファイルを削除すると発生。
composer dump-autoload後、
php artisan make:migraiton create_articles_table
が実行可能になる。