{"action":"created","issue":{"url":"https://api.github.com/repos/hyn/multi-tenant/issues/693","repository_url":"https://api.github.com/repos/hyn/multi-tenant","labels_url":"https://api.github.com/repos/hyn/multi-tenant/issues/693/labels{/name}","comments_url":"https://api.github.com/repos/hyn/multi-tenant/issues/693/comments","events_url":"https://api.github.com/repos/hyn/multi-tenant/issues/693/events","html_url":"https://github.com/hyn/multi-tenant/issues/693","id":391466066,"node_id":"MDU6SXNzdWUzOTE0NjYwNjY=","number":693,"title":"Driver [redis_tenancy] is not supported.","user":{"login":"Nowi5","id":27913135,"node_id":"MDQ6VXNlcjI3OTEzMTM1","avatar_url":"https://avatars0.githubusercontent.com/u/27913135?v=4","gravatar_id":"","url":"https://api.github.com/users/Nowi5","html_url":"https://github.com/Nowi5","followers_url":"https://api.github.com/users/Nowi5/followers","following_url":"https://api.github.com/users/Nowi5/following{/other_user}","gists_url":"https://api.github.com/users/Nowi5/gists{/gist_id}","starred_url":"https://api.github.com/users/Nowi5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nowi5/subscriptions","organizations_url":"https://api.github.com/users/Nowi5/orgs","repos_url":"https://api.github.com/users/Nowi5/repos","events_url":"https://api.github.com/users/Nowi5/events{/privacy}","received_events_url":"https://api.github.com/users/Nowi5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-16T13:12:38Z","updated_at":"2018-12-17T15:32:49Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nrelated to Make cache handling better for tenants #309 I get the issue of getting the error Driver [redis_tenancy] is not supported. \r\nCurrently I setup my own CI/CD process with local docker (base on php:7.1.8-apache), gitlab and production server. This seems to be related to some autogenerated loading of composer or so as it seems nearly to be random when it works and when not.\r\n\r\n![grafik](https://user-images.githubusercontent.com/27913135/50053500-91f31700-0136-11e9-8a5d-b9a6b5d39484.png)\r\n\r\n- hyn/multi-tenant version: hyn/multi-tenant 5.3.1  \r\n- laravel version:  laravel/framework v5.6.39 \r\n- webserver software and version: apache\r\n- php version: PHP 7.1.8 (cli) (built: Aug  4 2017 18:55:44) ( NTS )\r\n\r\nComposer:\r\n```\r\n    \"extra\": {\r\n        \"laravel\": {\r\n            \"dont-discover\": [\r\n\t\t\t\t\"hyn/multi-tenant\",\r\n\t\t\t\t\"spatie/laravel-permission\"\r\n            ]\r\n        },\r\n```\r\n\r\nconfig/app\r\n```\r\n     /*\r\n         * Laravel Framework Service Providers...\r\n         */\r\n        Illuminate\\Auth\\AuthServiceProvider::class,\r\n        ...\r\n\r\n\t// Needs to be before Hyn\\Tenancy: https://github.com/hyn/multi-tenant/issues/309#issuecomment-401509408\r\n\tApp\\Providers\\AppServiceProvider::class,\r\n\tApp\\Providers\\CacheServiceProvider::class,\t\t\r\n\t\t\r\n        /*\r\n         * Package Service Providers...\r\n         */\t   \r\n        Hyn\\Tenancy\\Providers\\TenancyProvider::class,\r\n        Hyn\\Tenancy\\Providers\\WebserverProvider::class,\r\n        Spatie\\Permission\\PermissionServiceProvider::class,\r\n        ...\r\n\r\n        /*\r\n         * Application Service Providers...\r\n         */\r\n        App\\Providers\\HelperServiceProvider::class,        \r\n        App\\Providers\\AuthServiceProvider::class,\r\n        App\\Providers\\ComposerServiceProvider::class,\r\n        // App\\Providers\\BroadcastServiceProvider::class,\r\n        App\\Providers\\EventServiceProvider::class,\r\n        App\\Providers\\RouteServiceProvider::class,\t    \r\n       ...\r\n```\r\n\r\nconfig/cache.php\r\n```\r\nreturn [\r\n    'default' => env('CACHE_DRIVER', 'file'), // in env = redis\r\n    'stores' => [\r\n        ...\r\n        'redis' => [\r\n            'driver' => 'redis_tenancy', //'redis', 'redis_tenancy'\r\n            'connection' => 'default',\r\n        ],\r\n    ],\r\n    'prefix' => env(\r\n        'CACHE_PREFIX',\r\n        str_slug(env('APP_NAME', 'laravel'), '_').'_cache'\r\n    ),\r\n];   \r\n```   \r\n\r\nCacheServiceProvider:\r\n```\r\n<?php\r\n\r\nnamespace App\\Providers;\r\n\r\nuse Illuminate\\Support\\ServiceProvider;\r\nuse Illuminate\\Support\\Facades\\Cache;\r\nuse Illuminate\\Support\\Facades\\DB;\r\nuse Illuminate\\Cache\\RedisStore;\r\n\r\nclass CacheServiceProvider extends ServiceProvider\r\n{\r\n    /**\r\n     * Bootstrap services.\r\n     *\r\n     * @return void\r\n     */\r\n    public function boot()\r\n    {\t\r\n\r\n        // https://github.com/hyn/multi-tenant/issues/309\r\n\t\tCache::extend('redis_tenancy', function ($app) {\r\n       \t\tif (PHP_SAPI === 'cli') {\r\n\t            $uuid = $app['config']['driver'];\r\n\t        } else {\r\n\t            // ok, this is basically a hack to set the redis cache store\r\n\t            // prefix to the UUID of the current website being called\r\n\t            $fqdn = $_SERVER['SERVER_NAME'];\r\n            \r\n\t            $uuid = DB::table('hostnames')\r\n\t                ->select('websites.uuid')\r\n\t                ->join('websites', 'hostnames.website_id', '=', 'websites.id')\r\n\t                ->where('fqdn', $fqdn)\r\n\t                ->value('uuid');\r\n\t        }\r\n\r\n\t        return Cache::repository(new RedisStore(\r\n\t            $app['redis'],\r\n\t            $uuid,\r\n\t            $app['config']['cache.stores.redis.connection']\r\n\t        ));\r\n\t    });\t\r\n    }\r\n\r\n    /**\r\n     * Register services.\r\n     *\r\n     * @return void\r\n     */\r\n    public function register()\r\n    {\r\n\t\r\n    }\r\n}\r\n```\r\n\r\nAny idea what is going wrong here? I think the boot of CacheServiceProvider is not loaded early enough, but how to change this?\r\n\r\nWhile writing this, I located this: https://stackoverflow.com/a/53263914/1597218\r\nThe order in the config/app is not used as expected. In my case the order is the following:\r\n1. Illuminate\r\n2. 3rd Party (which may will use Cache as well)\r\n3. Rest of app/config including CacheServiceProvider, Hyn & App\\\r\n\r\n\"According to the Application::registerConfiguredProviders it's hardcoded to have everything that starts with 'Illuminate\\' to go to the starting chunk, all others to the end, and Composer Packages go in the middle. \"\r\n\r\nEven so I add all missing 3rd Party provider into the app/config manually, the Application::registerConfiguredProviders list the providers twice.\r\nSo one option would be that this package add this provider to the default settings, as vendor files are loaded before app providers or alternativly adding a customIlluminate namespace. \r\n"},"comment":{"url":"https://api.github.com/repos/hyn/multi-tenant/issues/comments/447886675","html_url":"https://github.com/hyn/multi-tenant/issues/693#issuecomment-447886675","issue_url":"https://api.github.com/repos/hyn/multi-tenant/issues/693","id":447886675,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Nzg4NjY3NQ==","user":{"login":"luceos","id":504687,"node_id":"MDQ6VXNlcjUwNDY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/504687?v=4","gravatar_id":"","url":"https://api.github.com/users/luceos","html_url":"https://github.com/luceos","followers_url":"https://api.github.com/users/luceos/followers","following_url":"https://api.github.com/users/luceos/following{/other_user}","gists_url":"https://api.github.com/users/luceos/gists{/gist_id}","starred_url":"https://api.github.com/users/luceos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luceos/subscriptions","organizations_url":"https://api.github.com/users/luceos/orgs","repos_url":"https://api.github.com/users/luceos/repos","events_url":"https://api.github.com/users/luceos/events{/privacy}","received_events_url":"https://api.github.com/users/luceos/received_events","type":"User","site_admin":false},"created_at":"2018-12-17T15:32:49Z","updated_at":"2018-12-17T15:32:49Z","author_association":"MEMBER","body":"@JGamboa can you clarify what you did that solved your issue? We'd love to improve the docs and implementation for everyone."}}
{"actor":{"display_login":"luceos"}}