archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.66k stars 429 forks source link

ErrorException Invalid argument supplied for foreach() #247

Closed jbov closed 4 years ago

jbov commented 4 years ago

Describe the bug

appears to be the same error as previously reported on a fresh Laravel 6 installation. [2.2] ErrorException : Invalid argument supplied for foreach() TenancyServiceProvider.php:81#222 However in my case php artisan config:clear did not help.

Steps to reproduce

php artisan tenancy:install

ErrorException : Invalid argument supplied for foreach()

at /Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php:34 30| $this->app->bind(Tenant::class, function ($app) { 31| return $app[TenantManager::class]->getTenant(); 32| }); 33|

34| foreach ($this->app['config']['tenancy.bootstrappers'] as $bootstrapper) { 35| $this->app->singleton($bootstrapper); 36| } 37| 38| $this->app->singleton(Commands\Migrate::class, function ($app) {

Exception trace:

1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "/Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php", []) /Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php:34

2 Stancl\Tenancy\TenancyServiceProvider::register() /Applications/MAMP/htdocs/ws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:609

Please use the argument -v to see more details.

Expected behavior

A clear and concise description of what you expected to happen.

Your setup

stancl commented 4 years ago

Could you share the repository with me?

jbov commented 4 years ago

https://github.com/jbov/ws2/invitations

On 12/16/19 1:15 PM, Samuel Štancl wrote:

Could you share the repository with me?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/stancl/tenancy/issues/247?email_source=notifications&email_token=AB62WZCIZ2QPUXDVKXDOIFLQY7AUHA5CNFSM4J3N4M6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG7TDLI#issuecomment-566178221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB62WZDCATVWVFZVJM2POZ3QY7AUHANCNFSM4J3N4M6A.

stancl commented 4 years ago
git clone https://github.com/jbov/ws2
cd ws2
composer install
php artisan tenancy:install

works for me.

jbov commented 4 years ago

I just tried another fresh laravel installation and received the same error.  I believe you have an issue with the latest version of Laravel.

composer require stancl/tenancy Using version ^2.2 for stancl/tenancy ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals   - Installing stancl/tenancy (v2.2.4): Loading from cache Writing lock file Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi

   ErrorException  : Invalid argument supplied for foreach()

  at /Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php:34     30|         $this->app->bind(Tenant::class, function ($app) {     31|             return $app[TenantManager::class]->getTenant();     32|         });     33|   > 34|         foreach ($this->app['config']['tenancy.bootstrappers'] as $bootstrapper) {     35|             $this->app->singleton($bootstrapper);     36|         }     37|     38| $this->app->singleton(Commands\Migrate::class, function ($app) {

  Exception trace:

  1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "/Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php", []) /Applications/MAMP/htdocs/ws2/vendor/stancl/tenancy/src/TenancyServiceProvider.php:34

  2   Stancl\Tenancy\TenancyServiceProvider::register() /Applications/MAMP/htdocs/ws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:609

  Please use the argument -v to see more details. Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

On 12/16/19 2:35 PM, Samuel Štancl wrote:

|git clone https://github.com/jbov/ws2 cd ws2 composer install php artisan tenancy:install |

works for me.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/stancl/tenancy/issues/247?email_source=notifications&email_token=AB62WZFRCVDAVX5Q5YEXRHTQY7KATA5CNFSM4J3N4M6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG72YQQ#issuecomment-566209602, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB62WZBNU54OW2XWF62NGNLQY7KATANCNFSM4J3N4M6A.

stancl commented 4 years ago

Works for me on 6.7.0, even after running composer update.

antonio-aguirre commented 4 years ago

Hi, i have the same error. can you help me @stancl please

I did these steps:

-First I wrote in command line composer require stancl/tenancy but appear the same issues mentioned at the top.

I don't know why, I installed the same package with the same Laravel version (6.18.3) in another project and this have no problem.

My GitHub project: https://github.com/antonio-aguirre/FAQ-ZOOM.git

stancl commented 4 years ago

Show me the stack trace.

antonio-aguirre commented 4 years ago

Show me the stack trace.

MacBook-Pro-de-Antonio:FAQ-Zoom antonioaguirre$ composer require stancl/tenancy Using version ^2.3 for stancl/tenancy ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals

Installation failed, reverting ./composer.json to its original content.

stancl commented 4 years ago

Did you run this? Do you have a tenancy config file already in your config directory?

php artisan clear
stancl commented 4 years ago

Also note that if you ran php artisan tenancy:install, you can't just re-install the package using that command due to the changes it did to your Http Kernel.

antonio-aguirre commented 4 years ago

Did you run this? Do you have a tenancy config file already in your config directory?

php artisan clear

I have a new project, only with minor modifications, and all this happened when I tried to install the package.

I ran the php artisan clear command but nothing happened.

but right now I ran the package installation command again and nothing bad happened anymore ... this was weird but I'm calm for now.

I must say thank you for your time to respond, and your package has helped me a lot in another project!