Download the PHP package gpopoteur/flat without Composer

On this page you can find all versions of the php package gpopoteur/flat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flat

Flat

WORK IN PROGRESS!!

Laravel 5 package for creating multi-tenant apps. As of right now only Postgresql Schemas and SQLite Databases are supported.

Install

Install via composer with the command:

composer require gpopoteur/flat

Then register the provider in the config/app.php file:

After that you can start using the Flat API! :)

The Database driver used by flat will be the same one specified in config/database.php, meaning the same that you are using for your application.

Usage

You can inject the dependency with Laravel IoC container:

Or just let the App::make() resolve the class.

Creating a new Flat

To create a new Flat (Tenant), just call the build($name) method of the Flat class passing the new Tenant name.

After you create a new tenant, the new Schema is not automatically migrated, to run the migrations just run:

or, if migrating several tenants at once, pass an array with the tenants names:

Changing Flats (Tenants)

To change the Tenant programatically you can call the moveIn($name) method of the Flat API.

There is a middleware implemented called FlatCheckInMiddleware, basically what it does is to take the name of the variable flatName and change the user to that Schema.

To register this middleware you need to add the following line to the $routeMiddleware variable in the app/Http/Kernel.php file:

and you should be ready to go.

Example:

Subdomain tenant

To be able to do a subdomain tenant, just add a flatName variable and the flatCheckIn middleware to your domain route group.

Route name tenant

Because the flatName variable is assigned in the route, you can add that variable to any route group that fits your need, example:

When using the provided Middlewares, if a tenant doesn't exists the middleware will throw a new FlatDoesntExistsException that you can catch globally in the app and then redirect the user somewhere and show then a nice error message.

Contributing

Contributions to the library are more than welcome. To contribute code to this repo, follow this simple steps:

  1. Fork this project.
  2. Create a new branch. Ex: feature/this-thing
  3. Commit & Push the changes to your repo.
  4. Do a Pull Request from your branch to the develop branch of this repo.

Thanks :)

Disclaimer

Because this package works with the database, and the data is the more critical part of a production app I make the following statement:

I am not responsible in any way for any harm that this library does to your data. This package comes as-is. Use at your own risk.

License

MIT


All versions of flat with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gpopoteur/flat contains the following files

Loading the files please wait ....