tenancy / multi-tenant

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant
https://tenancy.dev
MIT License
2.55k stars 392 forks source link

Always show 404 error when connect default database. #368

Closed sahidhossen closed 6 years ago

sahidhossen commented 6 years ago

Description When open default domain for access default database its always show 404.php and no routes working. I have setup [tenant] database setting in database.php . But when open tenancy hostname its working fine.

maindomain.com -> 404.php -dev.tenant_1 -> working good -dev.tenant_2 -> working good ..


Actual behavior maindomain.com -> 404.php for default connection! ..

Expected behavior maindomain.com need to be work prefect for default database connection. ..


Information


tenancy.php config As default!

webserver.php config As Default


Error log No error log!

PiranhaGeorge commented 6 years ago

Find this line in tenancy.php, and set it to false.

'abort-without-identified-hostname' => true,

sahidhossen commented 6 years ago

It is already set true. I want default database connection when tenant hostname not resolve.

sahidhossen commented 6 years ago

Its working by set it false.

'abort-without-identified-hostname' => false

Thanks for your help!

pcfjojo commented 6 years ago

InvalidArgumentException Database [tenant] not configured.

'system' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ],

`APP_NAME=Laravel APP_ENV=local APP_KEY=base64:0UFyNXefjtqWt60thnxrtE7yN4k7QH0rLTI4e1HfE4Y= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL_BASE=localhost:8000
APP_URL=http://${APP_URL_BASE}

DB_CONNECTION=system DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=tenancy DB_USERNAME=root DB_PASSWORD=

BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379

MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null

PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET=

LIMIT_UUID_LENGTH_32=true AUTO_DELETE_TENANT_DIRECTORY=true AUTO_DELETE_TENANT_DATABASE=true `

Can you help me to resolve this problelm?

luceos commented 6 years ago

@pcfjojo next time please create an issue of your own.

You might need to enable early identification which will enable a middleware to identify tenants early in the Laravel ecosystem.

pcfjojo commented 6 years ago

Now I pass the error what i had.. but now i have another error Target [Hyn\Tenancy\Contracts\CurrentHostname] is not instantiable. I changed 'abort-without-identified-hostname' => false, in tenancy.php.

stil i have this error.. i am new to github.. sorry for creating issue inside.

luceos commented 6 years ago

@pcfjojo create a new issue or join us on discord, see https://laravel-tenancy.com