LoginSignup
0
0

More than 1 year has passed since last update.

PHP use演算子を用いたエイリアス作成で指定クラス名とは別名でエイリアスを作成する(asを使う)個人メモ

Posted at

目的

  • use演算子を用いたエイリアス作成時にクラス名とは異なる名前でエイリアスを作成する方法をまとめる

情報

  • 下記のように記載することでクラスのエイリアスを作成する。

    use App\Repositories\UserRepositoryInterface;
    
  • 上記use演算子が記載されたクラスで作成されたエイリアスのクラスを用いて処理を実行するときはUserRepositoryInterfaceが使用される。

方法

  • 下記のようにエイリアス作成時にasを用いて記載することで実際のクラス名とは別名のエイリアスを作成することができる。

    use App\Repositories\UserRepositoryInterface as UserRepository;
    
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