0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHP/Laravelで使うコマンド一覧

0
Posted at

PHP/Laravelで使うコマンドを一覧としてまとめた忘備録になります。
こちらは随時、更新していきます。

illuminate/consoleを含めたプロジェクト作成コマンド

composer create-project laravel/laravel プロジェクト名 --prefer-dist

パッケージインストール

composer install

APP_KEY生成

php artisan key:generate

サーバー起動

php artisan serve

モデル・ファクトリー・マイグレーション・シーダーを一括作成

php artisan make:model モデル名 -mfs

モデル作成

php artisan make:model Hello

ファクトリー作成

php artisan make:factory Hello

マイグレーション作成

php artisan make:migration create_tests_table --create=tests

マイグレーション

php artisan migrate

直前のマイグレーションをロールバック

php artisan migrate:rollback

マイグレーション状況を出力

php artisan migrate:status

全てのマイグレーション実行をロールバック

php artisan migrate:reset

全てのテーブルを削除してマイグレーションし直す

php artisan migrate:fresh

全てロールバックしてからマイグレーションし直す

php artisan migrate:refresh

新しいカラムを追加

php artisan make:migration add_new_column_to_table

## new_columnとtableを置き換える

カラムを削除

php artisan make:migration remove_column_from_table

## columnとtableを置き換える

マイグレーション&&シーダー実行

php artisan migrate --seed

シーダー作成

php artisan make:seeder UserSeeder

全てのシーダーを実行

php artisan db:seed

特定のシーダーを実行

php artisan db:seed --class=UserSeeder

コントローラーを作成

php artisan make:controller HelloController

リソースのメソッドを含んだコントローラーを作成

php artisan make:controller HelloController --resource

シングルアクションコントローラーを作成

php artisan make:controller SampleController --invokable

ルーティングの一覧を出力

php artisan route:list

ルーティングの中から特定ルートを出力

php artisan route:list | grep “指定ルート”

Requestクラスを新規作成

php artisan make:request Request名

アプリケーションキャッシュをクリア

php artisan cache:clear

設定ファイルのキャッシュをクリア

php artisan config:clear

ルートのキャッシュをクリア

php artisan route:clear

viewのキャッシュをクリア

php artisan view:clear

上記4つのキャッシュを一度にクリア

php artisan cache:clear && php artisan route:clear && php artisan config:clear && php artisan view:clear

単体テストを新規作成

php artisan make:test HelloTest --unit

結合テストを新規作成

php artisan make:test HelloTest

テストを実行

php artisan test
./vendor/bin/phpunit

特定のテストを実行

php artisan test tests/Feature/ExampleTest.php

## 特定のテストを実施するときはtests配下を指定
./vendor/bin/phpunit --filter ExampleTest

コマンド作成

php artisan make:command コマンド名

ジョブ作成

php artisan make:job SampleJob

phpstan実行

./vendor/bin/phpstan analyse
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?