Skip to content
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

Potential issues with Hyn Tenancy (View [auth.login] not found.) #112

Closed
robertdrakedennis opened this issue Jul 3, 2019 · 9 comments
Closed

Comments

@robertdrakedennis
Copy link

I'm currently trying to make a multi-tenant app that uses igaster themes to give tenants a bit of individuality. My main issue is in a tenants website the views arent being found and the themeViewFinder isn't actually being fired, or atleast I don't think it is.

https://hastebin.com/cifafamido.shell

^ error stack

What Illuminate\View\FileViewFinder:findInPaths returns:

"auth.login"
array:1 [▼
  0 => "/var/www/odin/resources/views"
]

I tried adding theme view finder in my app service provider to see if the paths were actually returning. My output was: https://hastebin.com/oqahuxiriv.php

When adding it to a middleware to test it down the pipeline:
https://hastebin.com/ofeyixigim.php

Further down the pipeline it actually adds the path, regardless of overriding view.finder down the pipeline it still returns the default view finder error in the stack. So I'm not sure if this is the main issue exactly is. Any advice?

@igaster
Copy link
Owner

igaster commented Jul 3, 2019

Hello @robertdrakedennis, this package is bootstrapped within ThemeServiceProvided which is being auto-discovered by Laravel. Thus there is no guarantee that you can interact with themes from any other Service Provider. A middleware is a safe place to use the themes.

However the in error stack that you shared I can't see the ThemeViewFinder being loaded (stack steps 79+80). Is it possible that the package is not loaded correctly? Try to resolve the Views Finder from the IoC inside your controller action: dd(app("view.finder")). Is this an instance of \Igaster\LaravelTheme\themeViewFinder?

@robertdrakedennis
Copy link
Author

First of all, thank you immensely for the quick response.

When I dump the IoC inside my controller right before the view is being called this is the entire output:

https://hastebin.com/jutijukoxi.php

That being said as you can see it is the theme view finder. I'll also go ahead and dump anything else you might find useful, please let me know if you need anything else.

Config (igaster/laravel-theme):
https://hastebin.com/jebowolesa.xml

Composer.json:
https://hastebin.com/ivofehiroq.bash

Config (hyn/tenancy):
https://hastebin.com/dubosovagi.xml

@robertdrakedennis
Copy link
Author

The main issue is I have no idea why themeViewFinder isn't in the error stack, but it's clearly being called through the pipeline, I've only experienced this issue the moment I started using hyn/tenancy

@igaster
Copy link
Owner

igaster commented Jul 3, 2019

a) So you haven't set some theme and it will pick the "default" theme.

Is this the intented behaviour? (check switching themes for instructions about setting current theme)

These are the paths where your views will be looked up:

  #paths: array:2 [▼
    0 => "/var/www/odin/resources/themes/default"
    1 => "/var/www/odin/resources/views"
  ]

b) In order to render a view from your theme you must define it a relative inside the theme folder...
ie view('aaa.bbb') will be resolved from /var/www/odin/resources/themes/default/aaa/bbb.blade.php

Can you verify that the view that you are trying to render exists in your current theme path?

@robertdrakedennis
Copy link
Author

Yes currently in my env I have the theme set as "default" as I don't have any other themes done right now.

https://i.imgur.com/wJBch3z.jpg

my env: https://hastebin.com/zaxusuqeka.ini

You can view here that there in indeed the view exists in the current theme path. If you need any other info from me please let me know.

@igaster
Copy link
Owner

igaster commented Jul 3, 2019

It seems fine... the login view should be picked from the theme path... Did you check the actual view path (ie with debug bar) and it is the default laravel view?

Also can you verify that the view search paths have not manipulated by some other part of the application (ie multitenant middleware?). Try to dump the viewfinder (dd(app("view.finder"))) just before you render the view (ie in your controller action). Are these correct?

@robertdrakedennis
Copy link
Author

Hi there, I believe I found the issue. In vendor\hyn\multi-tenant\src\Providers\TenancyProvider.php you can see the code:

    protected function registerProviders()
    {
        $this->app->register(Providers\ConfigurationProvider::class);
        $this->app->register(Providers\PasswordProvider::class);
        $this->app->register(Providers\ConnectionProvider::class);
        $this->app->register(Providers\UuidProvider::class);
        $this->app->register(Providers\BusProvider::class);
        $this->app->register(Providers\FilesystemProvider::class);
        $this->app->register(Providers\HostnameProvider::class);
        $this->app->register(Providers\DatabaseDriverProvider::class);
        $this->app->register(Providers\QueueProvider::class);

        // Register last.
        $this->app->register(Providers\EventProvider::class);
        $this->app->register(Providers\RouteProvider::class);
    }

When messing around trying to figure out the pipeline issue I added:

    protected function registerProviders()
    {
        . . .

        $this->app->register(\Igaster\LaravelTheme\themeServiceProvider::class);
    }

And the theme actually loads, I was thinking I should maybe bind hyn/tenancy's provider and just load your provider after. but I wasn't sure and wanted your opinion on it. As always I have greatly appreciated your patience.

@igaster
Copy link
Owner

igaster commented Jul 4, 2019

Hello @robertdrakedennis, if you wish to edit a package code then you must fork it and use your own version as a dependency. Not the best dev experience IMO!

I was checking this package and it allows the view paths to be moved into tenant directories... Maybe this is the reason that themes are not working. You can a) try to load themeServiceProvider after the TendantcyServiceProvider b) Disable this feature from config\tentant.php (check https://github.com/tenancy/multi-tenant/blob/5.x/assets/configs/tenancy.php#L391)

Let me know if this helps!

@robertdrakedennis
Copy link
Author

The config didn't seem to effect it, but we somewhat have a solution for it that just isn't pretty. If I find anything else out I'll let you know. Thank you so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants