-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: defining new namespace under app/
causes Cannot declare class ..., because the name is already in use
#5818
Comments
Oh, amazing!
$ git diff
diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php
index ee27e3b..f2ed2a3 100644
--- a/app/Config/Autoload.php
+++ b/app/Config/Autoload.php
@@ -43,6 +43,7 @@ class Autoload extends AutoloadConfig
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
+ 'MyNameSpace' => APPPATH . 'ThirdParty/MyFolder',
];
/** |
This is because of #3423 Try: --- a/composer.json
+++ b/composer.json
@@ -18,8 +18,6 @@
},
"autoload": {
"psr-4": {
- "App\\": "app",
- "Config\\": "app/Config"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
|
I think this is misconfiguration. I recommend you change the location of the folder, |
Cannot declare class ..., because the name is already in use
Cannot declare class ..., because the name is already in use
make:command --namespace
causes Cannot declare class ..., because the name is already in use
With this method, the error was temporarily solved. |
@kenjis ,thank you for your review and response. |
Why do you think so? If you really want to install in
At least, now I don't know there is a way to fix. |
Because each package can be installed in two ways.
Thank you for your answer. |
I don't think this is an effective solution! |
#3423 has been causing problems lately. I think we should revisit this. I agree with @datamweb that using either composer or manual should pose no issues in installation or use. #3423 is inclined to the composer way, thereby restricting manual installation usage. The solutions presented to both problems (including this one) caused by the change are both removing the |
make:command --namespace
causes Cannot declare class ..., because the name is already in use
app/
causes Cannot declare class ..., because the name is already in use
@paulbalandan |
…ser.json Revert codeigniter4#3423 Problems: - Cannot change `app` folder name. Because the composer's path overwrite the config in Config\Autoload. - Causes error when defining new namespace under app/. See codeigniter4#5818
I sent a PR to revet: #5824 I think now this issue is because of a bug in CI4 |
Can you show a failing test case where |
Can't write test code.
|
PHP Version
8.0
CodeIgniter4 Version
v4.1.9
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
--
What happened?
Problem in command
php spark make:command --namespace MyNameSpace
Steps to Reproduce
php spark make:command --namespace MyNameSpace
Command class name : TeseCommand
File created: APPPATH\ThirdParty\MyFolder\Commands\TeseCommand.php
Everything is done well.
The corresponding file is created.
But now typing command
php spark
displays the following error!Expected Output
@paulbalandan , @kenjis need to check to fix the problem. Please check.
Anything else?
This problem only exists in the installation method through composer .
This problem does not exist in the manual installation method.
The text was updated successfully, but these errors were encountered: