/config以下のファイル内容の更新が反映されない場合
Laravel5.4 + cloud9 php artisan migrate error
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 でエラーデータベースを作っていた場合は手動でデータベースを削除した後に設定をし直す
- Add the following to the app/Providers/AppServiceProvider boot method:
Schema::defaultStringLength(191);
- Don't forget to include the following at the top of the file:
use Illuminate\Support\Facades\Schema;
参考:
Laravel5.4 php artisan make:migration エラー処理
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
が実行可能になる。
Laravel 5.4 laravel-mix issue
laravelインストール後
→npm install
→npm run dev
→ミックスされたapp.js生成
→TypeError: Cannot read property 'csrfToken' of undefined
→もう一度npm run dev→error: jsにエラーがあるため
各々のファイルに
①
<script> window.Laravel = <?php echo json_encode([ 'csrfToken' => csrf_token(), ]); ?> </script>
または、
②
<script> window.Laravel = {!! json_encode([ 'csrfToken' => csrf_token(), ]) !!}; </script>
を埋め込むか
③
resources/assets/js/app.jsに
window.$ = window.jQuery = require('jquery');
window.Laravel = { csrfToken: $('meta[name=csrf-token]').attr("content") };
require('/bootstrap');
を加筆後、npm run dev
①②の場合app.jsに直接記述してnpm run devするとエラーになるため都度ファイルに書き込む
参考:
cloud9にphp7とLaravel5.xをインストール
updated: 2021/5/15
- sudo composer self-update
- sudo composer global require 'laravel/installer'
- export PATH=~/.composer/vendor/bin:$PATH
- nvm install stable → nodeをupdateしないとlaravel mixでerror
- nvm alias default [最新version](インストールされた最新のnodeのversionをdefaultに指定)
- npm install npm@latest -g
- Add the following to the app/Providers/AppServiceProvider boot method:
Schema::defaultStringLength(191);
- Don't forget to include the following at the top of the file:
use Illuminate\Support\Facades\Schema;
- resources/assets/js/app.jsに以下を加筆(laravel mixでのエラー回避のため)
window.$ = window.jQuery = require('jquery');
window.Laravel = { csrfToken: $('meta[name=csrf-token]').attr("content") };
require('/bootstrap');
______________________________________________________________
参考:
composer使用時に
cannnot create cache directoryが表示されたら
sudo chown -R $USER $HOME/.composer
参考:
追記:
pusher を使うならcurlをインストール
sudo apt-get install php7.1-curl
参考:
Cloud9 で Laravel(v5.5.0) をインストールして Dusk を動かす方法 – OBOEGAKI