I am adding a new PHP file to an existing Controllers folder. I am trying to insert the same "use" declarations into my new file as in the other existing controller files within this same folder. When I try to copy over the use declarations into my file and then press save the "use" declaration code disappears!

Here's the use statements I am trying to insert that disappears when I hit save:

use \Mobileplans\Api\Data\VirtualnumbersInterface;
use \Mobileplans\Api\VirtualnumbersRepositoryInterface as VirtualnumbersRepository;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\JsonFactory;

The only use declaration code block that saves to this new file without disappearing is:

use Magento\Backend\App\Action\Context;

The cause for the use statements disappearing was that my IDE was cleaning out any use statements that were not being used in my file. Once I added code that utilized the class I was trying to use, the use statement stopped disappearing.


Everything outside of a pair of opening and closing tags is ignored by the PHP parser which allows PHP files to have mixed content. This allows PHP to be embedded in HTML documents. blog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.