Skip to content

Import issue with Facade #1868

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

Closed
podcasthosting opened this issue Nov 7, 2019 · 8 comments · Fixed by #1968
Closed

Import issue with Facade #1868

podcasthosting opened this issue Nov 7, 2019 · 8 comments · Fixed by #1968
Assignees
Labels

Comments

@podcasthosting
Copy link

podcasthosting commented Nov 7, 2019

First off thank you for this great library!

In vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php you changed line 16

if (config('queue.failed.database') == 'mongodb') {

in version 3.6.0 to

if (DB::connection(config('queue.failed.database'))->getDriverName() == 'mongodb') {

in version 3.6.1 (line 17).

You import the DB facade with the statement

use DB;

causing a conflict in my application with a legacy class named DB that does not use a namespace.

It causes a

Cannot declare class, because the name is already in use

Could you please change the import to the complete path:

use Illuminate\Support\Facades\DB;

which solves the issue.

I´d appreciate that very much. Thank you!

@podcasthosting
Copy link
Author

@podcasthosting please add description

Please see updated issue. Sorry, I hit the send button accidentally.

@Smolevich
Copy link
Contributor

Is this facade occur error?

@podcasthosting
Copy link
Author

Is this facade occur error?

Sorry, I do not understand your question. Yes, this causes an error as described above.

@Smolevich
Copy link
Contributor

I install version 3.6.1 and don't catch errors with work eloquent models
Show test code for reproducing problem

@podcasthosting
Copy link
Author

podcasthosting commented Nov 7, 2019

As I wrote it conflicts with a legacy class called DB that is not using a namespace.

Just add a class

class DB {}

to your code and you´ll see.

@Smolevich
Copy link
Contributor

namespace App;

class DB {
    public const NAME='CUSTOM CLASS';
}

and successfully use this class and Illuminate\Support\Facades\DB together

@podcasthosting
Copy link
Author

I cannot modify the class because it comes from a library (Pear DB).

Why can´t you just modify the import statement to the full path as outlined above?

@divine divine added the bug label Feb 18, 2020
@divine divine self-assigned this Feb 18, 2020
divine added a commit to divine/laravel-mongodb that referenced this issue Feb 23, 2020
PR mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb#1868
@divine
Copy link
Contributor

divine commented Feb 23, 2020

Hi @podcasthosting,

Sorry about late fix, I've pushed a PR #1968 it will be merged and new version released as well.

Thank you!

softdevee added a commit to softdevee/laravel-mongodb that referenced this issue Sep 5, 2022
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
lisadeloach63 added a commit to lisadeloach63/mongodb-laravel that referenced this issue Oct 7, 2022
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
PermitinYury pushed a commit to PermitinYury/laravel-mongodb that referenced this issue Feb 17, 2023
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
KarenEtheridg pushed a commit to KarenEtheridg/laravel-mongodb that referenced this issue Feb 17, 2023
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this issue Sep 2, 2024
PR mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb#1868
Giant775 added a commit to Giant775/laravel_MongoDB that referenced this issue Nov 15, 2024
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
dev-arrow added a commit to dev-arrow/laravel-mongodb that referenced this issue Nov 26, 2024
PR mongodb/laravel-mongodb#1851 had incorrect class import, we need to define correct path, see issue mongodb/laravel-mongodb#1868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants