1
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?

More than 3 years have passed since last update.

Cannot declare class (クラス名), because the name is already in useの対策

Last updated at Posted at 2021-05-13
(ファイル名) % php artisan migrate

を行うと

Cannot declare class AddGoogleIdColumn, because the name is already in use

というエラーが出ました。この内容としては、「そのクラス名宣言できませんよ。既に使われていますよ」とのことでした。
しかし、クラス名で検索しても他に重複は見つかリませんでした。調べてみるとnamespaceを変えると解決しましたという記事も見かけました。

namespaceとは

namespaceとは、PHPで名前空間(エイリアス)を設定するために使用されるものです。
一般的にPHPフォルダーのはじめにnamespace <ファイルのパス>と記載します。
エイリアスをファイルのパスにすることで自動読み込みを行うことができるようにしています。

解決策

ファイル名でした!そのため以前のファイル名に復元させるとエラーは治りました!

% php artisan migrate:fresh

で、やってみるのもありだと思います。

1
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
1
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?