Download the PHP package sammycorgi/laravel-hierarchy without Composer

On this page you can find all versions of the php package sammycorgi/laravel-hierarchy. 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 laravel-hierarchy

laravel-hierarchy

Single root node hierarchy implementation for Laravel

Installation

You can install the package via composer:

composer require sammycorgi/laravel-hierarchy

Publish the config by running the following console command:

php artisan vendor:publish --provider="Sammycorgi\LaravelHierarchy\HierarchyServiceProvider" --tag="config"

If using the EloquentPersister, publish the migration for HierarchyModelChildRecord by running the following console command:

php artisan vendor:publish --provider="Sammycorgi\LaravelHierarchy\HierarchyServiceProvider" --tag="migrations"

Also make sure to set hierarchy.eloquent.default_model in the config to your default HasHierarchy Model if you're going to use the EloquentPersister

Usage

Implement the Contracts\HasHierarchy interface on any Model. For ease, use the Traits\HasHierarchy trait to implement the methods automatically. By default, the ID/Parent ID properties are id and parent_id, respectively. Using this trait, whenever a record is created, deleted or one has its parent_id updated, all affected parents will have their persisted child IDs updated automatically (see below).

Inject (or otherwise instantiate) HierarchyServiceFactory and pass a Model which implements HasHierarchy into the getChildIdsFor() method to return a collection of IDs which belong to children of the passed model. Call the for() method to return a HierarchyService with dependencies automatically resolved. You may also pass arguments to this method to override the default dependencies.

Persisting Child IDs

This package makes use of persistence via the cache (by default) or eloquent for quicker fetching of a model's children. If you wish to implement your own persister, create a new class that implements the Contracts\PersistsHierarchyChildren interface.

The default persister is the CachePersister, but this can be modified in the config. Simply change hierarchy.persisters.default in the config to the value of another key in this array, or change the HIERARCHY_DEFAULT_PERSISTER in your .env file.

Whenever the hierarchy tree is built for a given model, the child IDs will be persisted forever using the CachePersister.

When using the EloquentPersister, the database will be used to persist these child IDs. New records will be added to the hierarchy_model_child_records table that include the model type, the child ID and the parent ID.

Fetching Models

By default, this package uses the EloquentHierarchyInstanceGetter to fetch HasHierarchy models. If you wish to implement your own instance getter, create a new class that implements the Contracts\GetsHierarchyInstances interface.

The default instance getter is the EloquentHierarchyInstanceGetter, but this can be modified in the config. Simply change hierarchy.instance_getters.default in the config to the value of another key in this array.


All versions of laravel-hierarchy with dependencies

PHP Build Version
Package Version
Requires php Version ^8
laravel/framework Version ^8
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 sammycorgi/laravel-hierarchy contains the following files

Loading the files please wait ...