visual studio code - VSCode - PHP - Update namespace and imports of other files after moving class
Get the solution ↓↓↓Does anyone know if it's possible to configure VSCode to have the following occur after moving a file to another locations?
- Update the namespace of the class/trait.
- Update the imports of all other files referencing this file.
For example, let's say I have the following classes insrc/app
:
src/app/Hello.php
<?php
namespace App;
class Hello {
...
}
src/app/Goodbye.php
<?php
namespace App;
use App\Hello;
class Goodbye {
...
}
I want to move mysrc/app/Hello.php
file intosrc/app/services/Hello.php
. The following should occur:
- The namespace changes from
namespace App
tonamespace App\Services
- The import in
src/app/Goodbye.php
changes fromuse App\Hello
touse App\Services\Hello
So then we will have:src/app/services/Hello.php
<?php
namespace App\Services;
class Hello {
...
}
src/app/Goodbye.php
<?php
namespace App;
use App\Services\Hello;
class Goodbye {
...
}
Can this be done with the PHP Intelephense or PHP Namespace Resolver extension, or by any other means?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: please make sure the php redis extension is installed and enabled.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.