Download the PHP package sivanandaperumal/closure-table without Composer

On this page you can find all versions of the php package sivanandaperumal/closure-table. 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 closure-table

ClosureTable

Build Status Latest Stable Version Total Downloads

Branches

  1. L4 supports Laravel 4
  2. L5.1 supports Laravel < 5.2
  3. L5.3 supports Laravel 5.2-5.3
  4. L5.4 supports Laravel 5.4
  5. master is for any actual Laravel version, so be careful

Hi, this is a database package for Laravel. It's intended to use when you need to operate hierarchical data in database. The package is an implementation of a well-known database design pattern called Closure Table. The package includes generators for models and migrations.

Installation

To install the package, put the following in your composer.json:

And to app/config/app.php:

Setup your ClosureTable

Create models and migrations

For example, let's assume you're working on pages. You can just use an artisan command to create models and migrations automatically without preparing all the stuff by hand. Open terminal and put the following:

All options of the command:

  1. --namespace, -ns [optional]: namespace for classes, set by --entity and --closure options, helps to avoid namespace duplication in those options
  2. --entity, -e: entity class name; if namespaced name is used, then the default closure class name will be prepended with that namespace
  3. --entity-table, -et [optional]: entity table name
  4. --closure, -c [optional]: closure class name
  5. --closure-table [optional], -ct: closure table name
  6. --models-path, -mdl [optional]: custom models path
  7. --migrations-path, -mgr [optional]: custom migrations path
  8. --use-innodb and -i [optional]: InnoDB migrations have been made optional as well with new paramaters. Setting this will enable the InnoDB engine.

That's almost all, folks! The ‘dummy’ stuff has just been created for you. You will need to add some fields to your entity migration because the created ‘dummy’ includes just required id, parent_id, position, and real depth columns:

  1. id is a regular autoincremented column
  2. parent_id column is used to simplify immediate ancestor querying and, for example, to simplify building the whole tree
  3. position column is used widely by the package to make entities sortable
  4. real depth column is also used to simplify queries and reduce their number

By default, entity’s closure table includes the following columns:

  1. Autoincremented identifier
  2. Ancestor column points on a parent node
  3. Descendant column points on a child node
  4. Depth column shows a node depth in the tree

It is by closure table pattern design, so remember that you must not delete these four columns.

Remember that many things are made customizable, so see ‘Customization’ for more information.

Time of coding

Once your models and their database tables are created, at last, you can start actually coding. Here I will show you ClosureTable's specific approaches.

Direct ancestor (parent)

Ancestors

Direct descendants (children)

Descendants

Siblings

Roots (entities that have no ancestors)

Entire tree

You deal with the collection, thus you can control its items as you usually do. Descendants? They are already loaded.

Moving

Deleting subtree

If you don't use foreign keys for some reason, you can delete subtree manually. This will delete the page and all its descendants:

Customization

You can customize default things in your own classes created by the ClosureTable artisan command:

  1. Entity table name: change protected $table property
  2. Closure table name: do the same in your ClosureTable (e.g. PageClosure)
  3. Entity's parent_id, position, and real depth column names: change return values of getParentIdColumn(), getPositionColumn(), and getRealDepthColumn() respectively
  4. Closure table's ancestor, descendant, and depth columns names: change return values of getAncestorColumn(), getDescendantColumn(), and getDepthColumn() respectively.

All versions of closure-table with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
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 sivanandaperumal/closure-table contains the following files

Loading the files please wait ....