multi-tenant | Run multiple websites using the same Laravel installation | Microservice library

 by   tenancy PHP Version: 5.8.0 License: MIT

kandi X-RAY | multi-tenant Summary

kandi X-RAY | multi-tenant Summary

multi-tenant is a PHP library typically used in Architecture, Microservice applications. multi-tenant has no vulnerabilities, it has a Permissive License and it has medium support. However multi-tenant has 1 bugs. You can download it from GitHub.

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. But with clear separation of assets, database and the ability to override logic per tenant. Suitable for marketing companies that like to re-use functionality for different clients or start-ups building the next software as a service. Complete documentation covers more than just the installation and configuration.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              multi-tenant has a medium active ecosystem.
              It has 2431 star(s) with 383 fork(s). There are 88 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 69 open issues and 626 have been closed. On average issues are closed in 69 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of multi-tenant is 5.8.0

            kandi-Quality Quality

              multi-tenant has 1 bugs (0 blocker, 0 critical, 1 major, 0 minor) and 35 code smells.

            kandi-Security Security

              multi-tenant has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              multi-tenant code analysis shows 0 unresolved vulnerabilities.
              There are 3 security hotspots that need review.

            kandi-License License

              multi-tenant is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              multi-tenant releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              multi-tenant saves you 1714 person hours of effort in developing the same functionality from scratch.
              It has 3797 lines of code, 361 functions and 155 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed multi-tenant and discovered the below as its top functions. This is intended to give you an instant insight into multi-tenant implemented functionality, and help decide if they suit your requirements.
            • Execute the migration command .
            • Register the migration commands .
            • Generate database configuration array .
            • Update a website .
            • Touch the website .
            • Read configuration files .
            • Replace variables .
            • Force hostname .
            • Read translation files .
            • Get the url path .
            Get all kandi verified functions for this library.

            multi-tenant Key Features

            No Key Features are available at this moment for multi-tenant.

            multi-tenant Examples and Code Snippets

            No Code Snippets are available at this moment for multi-tenant.

            Community Discussions

            QUESTION

            stancl/tenancy: How to fetch data from tenant db globally?
            Asked 2021-Jun-09 at 11:41

            I used to fetch data from db and make available in all View through ServiceProvider, But now, I am using stancl/tenancy for multi-tenant system. And I need to pass some global data to all view files, writing the fetch data in ServiceProvider returns data from central database only. So, how can I fetch data from tenant DB to all view files globally before requesting any other requests?

            ...

            ANSWER

            Answered 2021-Jun-09 at 11:41

            Service Providers run before the tenant is identified and can therefore not be used to make configurations like sharing data to all views.

            Instead, you can make a custom tenancy bootstrapper by creating a class that implements the Stancl\Tenancy\Contracts\TenancyBootstrapper interface.

            Source https://stackoverflow.com/questions/67902063

            QUESTION

            Why is Google Firebase not recommended by Google - in their own documentation - for multi-tenant applications?
            Asked 2021-Jun-02 at 06:00

            There is a warning on the Firebase best practices documentation against using Firebase with multi-tenant applications: https://firebase.google.com/docs/projects/learn-more#multi-tenancy

            This is what I am most concerned about: "Multi-tenancy can lead to serious configuration and data privacy concerns problems, including unintended issues with analytics aggregation, shared authentication, overly-complex database structures, and difficulties with security rules."

            There is also plenty of official Google documentation supporting the use of Firebase for multi-tenancy, for instance: https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication .

            Do you know why they would have these conflicting recommendations and examples? Does use of Google Identity Platform fix the core security deficits mentioned in the warning?

            I am re-posting this question, with additional clarification in the title, and a few edits/removals from the body, to specify that I am only looking for why this widely used product has this particular warning in its official documentation. I have removed most subjective content. I have no opinion on this that is relevant to the question - I am only looking to understand the warning. It seemed there was one good answer before the previous question was closed, so I will link that here for reference: Why is Google Firebase not recommended by Google in their own documentation for multi-tenant applications?

            ...

            ANSWER

            Answered 2021-Jun-02 at 06:00

            That does make sense if you manage 2 separate applications which have no relation with each other. Let's say you have an app that manages a school's information and other one is a restaurant management app. Now in this case I don't see any event that the school app might need access to restaurant data.

            If you use the same project, then all the firebase services (auth, database, analytics, etc) will be shared among them. It'll be hard for you to separate analytics for each of the app. As the database is shared, you'll have to explicitly separate data of both apps by separating the path in db. (/apps/school for school, /apps/restaurant for restaurant).

            That being said, any user registered on the school app can login on restaurant app without creating a new account there as you are sharing the same project among them.

            Now if your client pays you a the Firebase costs every month, you cannot distinguish between how much should the school client pay. Now even if both the apps are your, the complexity will increase significantly if you go on using it.

            https://firebase.google.com/docs/projects/learn-more#multi-tenancy <-- this explains how "Firebase Projects" works and https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication explains about "Google Identity Kit" multi-tenant auth. So that's not a Firebase-only thing.

            Source https://stackoverflow.com/questions/67798744

            QUESTION

            Why is Google Firebase not recommended by Google in their own documentation for multi-tenant applications?
            Asked 2021-Jun-01 at 20:34

            There is a warning on the Firebase best practices documentation against using Firebase with multi-tenant applications: https://firebase.google.com/docs/projects/learn-more#multi-tenancy

            This is what I am most concerned about: "Multi-tenancy can lead to serious configuration and data privacy concerns problems, including unintended issues with analytics aggregation, shared authentication, overly-complex database structures, and difficulties with security rules." Identity Platform looks like it should cover everything except analytics aggregation and database structures, but I can control analytics logging and my database structure is simple enough, being divided cleanly by tenant. My application is one common application, but has tenanted client data and users (managed via Google Identity Platform).

            There is also plenty of official Google documentation supporting the use of Firebase for multi-tenancy: https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication . There are also dozens of examples out there for how to set up multi-tenancy with Firebase and Google Identity Provider.

            Do you know why they would have these conflicting recommendations and examples? Does use of Google Identity Platform fix the core security deficits mentioned in the warning? It has me strongly considering abandoning Firebase, which would be a shame given the features it gives me.

            ...

            ANSWER

            Answered 2021-May-28 at 07:44

            The recommendation is not bind to Firebase, or GCP, or Google. It's generic. If you put all your data in the same bag, with only a logical isolation, it's only logical, not strong as different projects.

            Thus, it's easy to make a mistake and to use, delete, update, make the mess, in all the tenant data. In case of attacks, leak, major bug, you can reduce the blast radius by having several small tenant.

            It's a tradeoff between more management to perform (because you have a lot of tenant) and a higher risk (multi-tenant project, the crash is dramatic). It also depends on your application type and context. It's a recommendation, not an obligation!

            Source https://stackoverflow.com/questions/67727539

            QUESTION

            Using hotchocolate's filters with schema first approach
            Asked 2021-Jun-01 at 16:34

            I'm using a schema interceptor to configure my schema. It's a multi-tenant application, so I build the schema according to the tenant's configuration. I'm mapping that configuration to SDL language (schema-first approach) and then I add it to the schema builder (schemaBuilder.AddDocumentFromString(...)).

            As said on the documentation (here), "Schema-first does currently not support filtering!". But that is the only approach I can use right now, so I'm trying to find a workaround.

            What I've tried:

            Manually create the input filter types and add the filtering to the server (something like this):

            ...

            ANSWER

            Answered 2021-Jun-01 at 16:34

            Filter support for schema-first is coming with version 12. You then do not even have to specify everything since we will provide schema building directives.

            Source https://stackoverflow.com/questions/67792470

            QUESTION

            Multi-tenant rails application with a domain/subdomain architecture like Shopify
            Asked 2021-Jun-01 at 11:35

            I'm building a multi-tenant rails application, similar to Shopify. Whenever a customer registers an Account, they will have a subdomain created at customer.myapp.com. This subdomain returns a view with data related to their account (including a /admin area).

            Now in some cases, customers would like to use their own custom domain, instead of the subdomain created for them. How do I need to adjust my rails routes and controllers to return a view with data related to the customers account, based on not just the subdomain but on either the custom domain OR the subdomain?

            This is how I've set up my config/routes.rb for handling subdomains:

            ...

            ANSWER

            Answered 2021-Jun-01 at 11:35

            Okay, so this is what I came up with in the meantime.

            First of all I left my config/routes.rb as described above. Everything seemed to be working as intended there.

            Then I adjusted app/constraints/subdomain_required.rb to not only check for the subdomain but also the domain part of the request:

            Source https://stackoverflow.com/questions/67598909

            QUESTION

            PGBouncer IDLE Connections not Closing on Postgres
            Asked 2021-May-27 at 16:31

            We have a setup where we are running 6 PgBouncer processes and our performance benchmarks degrade linearly with time. The longer PgBouncer has been running, the longer the connections to Postgres exist results in slower response times for the benchmark. We have a multi-tenant schema separated database with 2000+ relations. We are configured for Transaction Mode pooling right now. Over time, we see the memory footprint of each Postgres process climb and climb and climb, and again, this results in poorer performance.

            We have tried to be more aggressive in cleaning up idle connections with the following settings:

            ...

            ANSWER

            Answered 2021-May-27 at 16:31

            The issue is resolved.

            The application was extremely chatty and even with server_idle_timeout set as low as 5 seconds, the connections were not getting recycled on the Postgres side.

            The issue we had was that server_lifetime was accidentally commented when we thought it was active and once we changed that, we could clearly see that Postgres connections were getting recycled every 2 minutes (based on our settings).

            The increased memory of each connection over time especially for long-lived connections was only taking into consideration private memory and not shared memory. What we observed was the longer the connection was alive, the more memory it consumed. We tried setting things like DISCARD ALL for reset_query and it had no impact on memory consumption. Based on my research online, we were not the only to ones to face this challenge with pooling connections.

            Thanks for the comments and the help. Our solution in the end was to leverage server_lifetime in pgBouncer to control the number of long-lived connections on Postgres.

            -Mayan

            Source https://stackoverflow.com/questions/67664415

            QUESTION

            Does Firestore support multitenancy?
            Asked 2021-May-26 at 12:23

            Does Firestore have any support for a multi-tenant app? I am creating a service which will have multiple clients and need to be able to separate each client's data completely from every other client.

            ...

            ANSWER

            Answered 2021-May-26 at 12:23

            Firestore in Native mode has no (built-in) support for multitenancy.

            Firestore in Datastore mode has support for multitenancy via namespaces. However, Firestore in Datastore mode loses the real-time updates feature, which is a highly desirable feature for many developers/projects.

            One workaround for this limitation is to use a (collection/document) hierarchy in the Native-mode Firestore that looks something like this:

            • tenants (collection)
              • Tenant-01 (document representing a particular tenant; can contain basic details like name etc.)
                • users (sub-collection)
                • assets (sub-collection)
                • locations (sub-collection)
              • Tenant-02
                • users (sub-collection)
                • assets (sub-collection)
                • locations (sub-collection)

            However, there still remains the limitation that you cannot know the resource usage on a per-tenant basis. This matters particularly when there's a noisy neighbour: a single tenant that is using far more resources than the average. As the service provider your total bill is rising, but there's no easy way to know which client (tenant) is causing the higher costs.

            See also:

            Source https://stackoverflow.com/questions/67704798

            QUESTION

            Get specific database connection string while logging and connect to that database dynamically in laravel 8?
            Asked 2021-May-19 at 14:15

            I developed a web accounting application using vanilla PHP as backend and jquery and vanilla javascript as frontend. Every client will have one database. The single database contains all client's database connection strings and login credentials for clients. Whenever a client logs in using a login credential client gets the connection string from the master database where all database connections are stored. Based on login credentials my backend will connect to their database. They will work on their database.

            How can i achieve this scenario using laravel 8? i tried several solutions like, Dynamic database connection in Laravel, Create Dynamic Database Connection in Laravel, Laravel 5.8 dynamic database connection not being set in model, laravel 5.4 dynamic database connection, Configure database connections on the fly in Laravel

            these all solutions recommend using configure file or .env file. as you can see in my scenario i can't setup every client's database connection in database config array because my client's database connections are dynamic and there are lots of database connections.

            so what you guys will suggest to overcome this scenario?

            and i don't want to use Multi-Tenant setup its just overkill and i do want is grab connection string while logging and use that connection string to connect user's specific database. so its kind a dynamic!

            ...

            ANSWER

            Answered 2021-May-19 at 05:56
            1. Add connection to config/database.php (You may copy and edit the name.) ex. copy and change name to "mysql_user"
            2. Make middleware
            3. Check auth in middleware and get credentials
            4. Set config in middleware

            Source https://stackoverflow.com/questions/67597079

            QUESTION

            Is there a way to customize the text content of Google One Tap prompt?
            Asked 2021-May-17 at 19:06

            Our application has a multi-tenant architecture where we have multiple different websites deployed using a single codebase. Is there a way to edit the application name (ie. show Sign in to with Google instead of Sign in to with Google) without needing to create a separate project in Google Console for each website?

            If editing the app name is impossible, is there a way to just show Sign in with Google instead?

            ...

            ANSWER

            Answered 2021-May-17 at 19:06

            I don't think Google allows you to do that, basically due to some legal/UX concerns. Take below UX as an example.

            1. Users go to website1, and see prompt for "App Name 1". Then grant it.
            2. Users go to website2, and see prompt for "App Name 2". And it'd be a big surprise, to some of them, that the permission has arleady been granted. Users may think 1)Google granted it without user's consent, or 2) someone had stolen his credentials and granted it, etc.

            In summary, you need to make a decision first:

            1. if you think end users should treat your different origins as different apps, you should create different projects for them(, so that their UX are isolated from each others).
            2. if you think users should treat your different origins as a single app, then using same app name is not an issue at all.

            Source https://stackoverflow.com/questions/67467417

            QUESTION

            Best way to generate (and save) incremental invoice numbers in a multi-tenant MySQL database
            Asked 2021-May-13 at 01:47

            I have found two different ways to, first, get the next invoice number and, then, save the invoice in a multi-tenant database where, of course, each tenant will have his own invoices with different incremental numbers.

            • My first (and actual) approach is this (works fine):
            1. Add a new record to the invoices tables. No matter the invoice number yet (for example, 0, or empty)
            2. I get the unique ID of THAT created record after insert
            3. Now I do a "SELECT table where ID = $lastcreatedID **FOR UPDATE**"
            4. Here I get the latest saved invoice number with "SELECT @A:=MAX(NUMBER)+1 FROM TABLE WHERE......"
            5. Finally I update the previously saved record with that invoice number with an "UPDATE table SET NUMBER = $mynumber WHERE ID = $lastcreatedID"

            This works fine, but I don't know if the "for update" is really needed or if this is the correct way to do this in a multi-tenant DB, due to performance, etc.

            • The second (and simpler) approach is this (and works too, but I don't know if it is a secure approach):
            1. INSERT INTO table (NUMBER,TENANT) SELECT COALESCE(MAX(NUMBER),0)+1,$tenant FROM table WHERE....
            2. That's it

            Both methods are working, but I would like to know the differences between them regarding speed, performance, if it may create duplicates, etc.

            Or... is there any better way to do this?

            I'm using MySQL and PHP. The application is an invoice/sales cloud software that will be used by a lot of customers (tenants).

            Thanks

            ...

            ANSWER

            Answered 2021-May-12 at 17:56

            Both the approaches do work, but each with its own demerits in high traffic situations.

            The first approach runs 3 queries for every invoice you create, putting extra load on your server.

            The second approach can lead to duplicates in events where two invoices are generated with very little time difference (such that the SELECT query return same max number for both invoices).

            Both the approaches may lead to problems in high traffic conditions.

            Two solutions to the problems are listed below:

            1. Use generated columns: Mysql supports generated columns, which are basically derived using other column values for each row. Refer this

            2. Calculate invoice number on the fly: Since you're using the primary key as part of the invoice, let the DB handle generating unique primary keys, and then generate invoice numbers on the fly in your business logic using the id for each invoice.

            Source https://stackoverflow.com/questions/67508564

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install multi-tenant

            You can download it from GitHub.
            PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.

            Support

            This package is offered under the MIT license. In case you're interested at contributing, make sure to read the contributing guidelines.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/tenancy/multi-tenant.git

          • CLI

            gh repo clone tenancy/multi-tenant

          • sshUrl

            git@github.com:tenancy/multi-tenant.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link