GithubHelp home page GithubHelp logo

archtechx / tenancy Goto Github PK

View Code? Open in Web Editor NEW
3.4K 77.0 401.0 2.87 MB

Automatic multi-tenancy for Laravel. No code changes needed.

Home Page: https://tenancyforlaravel.com

License: MIT License

PHP 99.31% Dockerfile 0.64% Shell 0.05%
laravel tenancy tenant multi-tenancy saas multitenancy software-as-a-service

tenancy's Introduction

Tenancy for Laravel logo

Laravel 10.x Latest Stable Version GitHub Actions CI status Donate

Automatic multi-tenancy for your Laravel app.

You won't have to change a thing in your application's code.

  • ✔️ No model traits to change database connection
  • ✔️ No replacing of Laravel classes (Cache, Storage, ...) with tenancy-aware classes
  • ✔️ Built-in tenant identification based on hostname (including second level domains)

Documentation can be found here: https://tenancyforlaravel.com/docs/v3/

The repository with the documentation source code can be found here: stancl/tenancy-docs.

Credits

tenancy's People

Contributors

abrardev99 avatar amirakbulut avatar antonkomarev avatar bepsvpt avatar bonroyage avatar caneco avatar chillbram avatar creeppork avatar cristiantudorache avatar domkrm avatar drbyte avatar erikgaal avatar franzyke avatar hackeresq avatar jonagoldman avatar jorgensolli avatar kg-bot avatar lukinovec avatar masiorama avatar mlajx avatar morloderex avatar nthndnn avatar nuradiyana avatar petecoop avatar seanmtaylor avatar shalawani avatar stancl avatar timothydc avatar vstyler96 avatar wilsenhc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tenancy's Issues

Predis support?

Perhaps predis could work if tenancy support for Redis was disabled in the config?

Allow tenants to use multiple domains

I'm not sure if there are many practical uses for this, but code-wise this shouldn't be hard to add.

Also add API to easily add and remove domains.

Add tests

  • all parts of BootstrapsTenancy - finished apart from tagCache()

PHP Parse error: Syntax error, unexpected T_DOUBLE_ARROW on line 1

I am getting error while while creating tenent in tinker

>>> tenant()->create('tenant1.localhost')
=> [
     "uuid" => "e5611150-9a9e-11e9-8315-b9eb127de2b8",
     "domain" => "tenant1.localhost",
   ]

Error

PHP Parse error: Syntax error, unexpected T_DOUBLE_ARROW on line 1

I tried on different projects , different php versions bu no luck.

I was following this article
https://stancl.github.io/blog/how-to-make-any-laravel-app-multi-tenant-in-5-minutes/

Thanks for this incredible package.

Better error messages

>>> tenancy()->findByDomain('laravel.localhostt')
TypeError: Argument 1 passed to Stancl/Tenancy/TenantManager::find() must be of the type string, null given, called in /var/www/laravel/test/vendor/stancl/tenancy/src/TenantManager.php on line 152

Add more database-related artisan commands

Perhaps some of these?

  • migrate:fresh Drop all tables and re-run all migrations
  • migrate:install Create the migration repository
  • migrate:refresh Reset and re-run all migrations
  • migrate:reset Rollback all database migrations
  • migrate:status Show the status of each migration

HTTPS certificates

When the yourclient.yourapp.com, yourclient2.yourapp.com model is used, a wildcard cert can take care of HTTPS. However, when the yourapp.yourclient.com, yourapp.yourclient2.com model is used, there needs to be some feature for HTTPS management. Luckily file-based verification can be used with Let's Encrypt, so perhaps creating a route to verify the domain ownership is sufficient? Auto renewal etc could be added too.

Changing the identified tenant breaks storage_path

>>> storage_path()
=> "/var/www/laravel/test/storage"
>>> tenancy()->all()
=> Illuminate\Support\Collection {#3181
     all: [
       [
         "uuid" => "8075a580-1cb8-11e9-8822-49c5d8f8ff23",
         "domain" => "dev.localhost",
       ],
       [
         "uuid" => "1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd",
         "domain" => "laravel.localhost",
         "abc" => "def",
       ],
     ],
   }
>>> tenancy()->init('dev.localhost')
=> [
     "uuid" => "8075a580-1cb8-11e9-8822-49c5d8f8ff23",
     "domain" => "dev.localhost",
   ]
>>> storage_path()
=> "/var/www/laravel/test/storage/tenant8075a580-1cb8-11e9-8822-49c5d8f8ff23"
>>> tenancy()->init('laravel.localhost')
=> [
     "uuid" => "1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd",
     "domain" => "laravel.localhost",
     "abc" => "def",
   ]
>>> storage_path()
=> "/var/www/laravel/test/storage/tenant8075a580-1cb8-11e9-8822-49c5d8f8ff23/tenant1e22e620-1cb8-11e9-93b6-8d1b78ac0bcd"

Check if it breaks anything else (write a test).

CacheManager doesn't merge the tags properly

>>> cache()->tags([1,2])->getTags()->getNames()
=> [
     1,
     2,
   ]
>>> tenancy()->init()
=> [
     "uuid" => "[...]",
     "domain" => "laravel.localhost",
     "foo" => [
       "a" => "b",
       "c" => "d",
     ],
   ]
>>> cache()->tags([1,2])->getTags()->getNames()
=> [
     "tenant45b1a950-2d81-11e9-a4f5-bf999e894159",
     [
       1,
       2,
     ],
   ]

Tenancy documentation and can it do the requested

@stancl
I stumbled upon your blog post, I will say i am really impressed by your package, I would say it remove 99% time meant for the development of multi-tenancy app.
But i hit a snag because i could not get the complete documentation.
I would love it if you could write more tutorials on how to build a panel/control dashboard to create, delete and suspend a tenant app.
Preferably continuing from your Tutorial.
I have an app which i am working which allow user's to send emails On the free plan and Limited number of SMS on the pro plan.
Currently i use hard coded variables for that. Something like this in my controller
$use_sms = true; if($use_sms === true){ //Function to send SMS }
How do i do such using your package..

Thanks.
Moneya

Better tenant-specific assets

Code like this is problematic:

public static function productImage($product_id)
{
    return asset("storage/images/products/$product_id.png");
}
\Image::make($image)
    ->resize(750, 750, $constraint)//->resizeCanvas(750, 750)
    ->save(storage_path("app/public/images/products/{$product->id}.png"))
    ->resize(300, 300, $constraint)//->resizeCanvas(300, 300)
    ->save(storage_path("app/public/images/products/thumbnails/{$product->id}.png"));

But code like this seems to work (= doesn't delete the image, since the code above put it in the wrong directory):

if (\Helper::imageExists($product->id) && $image_deleted) {
    Storage::delete("public/images/products/{$product->id}.png");
    Storage::delete("public/images/products/thumbnails/{$product->id}.png");
}
  • Try to fix storage_path() and asset()
    • app()->useStoragePath(app()->storagePath() . $path)
    • app('url')->forceRootUrl(asset('') . $url)
  • Add a class for global (non-suffixed) Storage (unrelated to this issue, but it might be a useful feature) #8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.