スキップしてメイン コンテンツに移動

Laravelでよく使うコマンド集

 ■クリア系コマンド

・キャッシュクリア

php artisan cache:clear

・configクリア

php artisan config:clear

・ビュークリア

php artisan view:clear


■リセット系コマンド

・データベースをリセットする

php artisan migrate:refresh

・データベースをロールバックする

php artisan migrate:reset


■テーブル、コントローラ、モデルを同時に作成する

php artisan make:model Groups -c -m

※Groupsは必ず複数形を使ってください。


■カラムの追加

php artisan make:migration add_column_group_id_options_table --table=options

・add

$table->bigInteger('group_id');


・drop

$table->dropColumn('group_id');


下記のコマンドを実行

php artisan migrate

追加完了!


■カラムの削除

php artisan make:migration remove_column_group_id_groups_table --table=groups

出来上がったファイルで、下記のコードを追加

・drop

$table->dropColumn('group_id');

・ロールバック

$table->bigInteger('group_id');

下記のコマンドを実行

php artisan migrate

削除完了!


※カラム名の変更で下記のエラーが出た場合、

Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found


下記のコマンドを実行すればいい。

#composer require doctrine/dbal


とりあえず、以上です。

ほかにあれば、随時更新する。


コメント

このブログの人気の投稿

gitよく使うコマンド集

よく使うgitのコマンド集をまとめてみた。 1.ローカルリポジトリの登録  #git init 2.gitの状態を確認  #git status 3.gitのファイルを追加  #git add . 4.ローカルのマスタにコミットする  #git commit -m "体温管理アプリの初期化" 5.リモートリポジトリを登録する  #git remote add origin https://github.com/ユーザーID/リポジトリ名  例)git remote add origin https://github.com/githubkyo/taionkanri 6. リモートリポジトリの変更履歴の取得 git fetch origin master 7.差分のあるファイル名を表示 > git diff --name-status ローカルブランチ名 origin/リモートブランチ名 【例】 > git diff --name-status master origin/master 8.リモートのファイルのみをローカルに反映する。 git checkout origin/master --src/Eccube/Resource/template/default/default_frame.twig 9.別ブランチをマスタへマージする git checkout master git merge other_branch 以上で、随時更新していく予定。

sendmailをgmail経由で送信する設定

 1.sendmail.iniで下記の設定を行う。 ------------------------------- smtp_server=smtp.gmail.com smtp_port=465 auth_username=youraccount@gmail.com auth_password=youraccountpassword force_sender=youraccount@gmail.com ------------------------------- 2.gmailでの設定 https://myaccount.google.com/securityへアクセスし、 安全性の低いアプリのアクセス 「オフ―」から「オン」に変える。 3.php.iniでsendmail_pathを設定する。 [mail function] ; For Win32 only. ; http://php.net/smtp ;SMTP = localhost ; http://php.net/smtp-port smtp_port = 465 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from ="admin@wampserver.invalid" ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "sendmailフォルダーのパス\sendmail.exe -t" 4.Apacheを再起動すれば、sendmailが使えるようになる。 以上です。