Download the PHP package mouf/schema-analyzer without Composer

On this page you can find all versions of the php package mouf/schema-analyzer. 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 schema-analyzer

Latest Stable Version Latest Unstable Version License Scrutinizer Code Quality Build Status Coverage Status

Schema analyzer for DBAL

This package offer utility functions to analyze database schemas. It is built on top of Doctrine DBAL.

In this package, you will find:

Installation

You can install this package through Composer:

The packages adheres to the SemVer specification, and there will be full backward compatibility between minor versions.

Detecting junction tables

The starting point is always a DBAL Schema. Pass the schema manager to SchemaAnalyzer, and then, simply call the functions.

A junction table is a table:

There is an optional parameter you can use with detectJunctionTables that will automatically ignore any junction table that is referenced by a foreign key of another table.

Detecting inheritance relationship between tables

About inheritance relationships

If a table "user" has a primary key that is also a foreign key pointing on table "contact", then table "user" is considered to be a child of table "contact". This is because you cannot create a row in "user" without having a row with the same ID in "contact".

Therefore, a "user" ID has to match a "contact", but a "contact" has not necessarily a "user" associated.

Detecting inheritance relationships

You can use SchemaAnalyzer to detect parent / child relationships.

Computing the shortest path between 2 tables

Following foreign keys, the getShortestPath function will try to find the shortest path between 2 tables. It will return the list of foreign keys it used to link the 2 tables.

Internals:

Heads up! The shortest path is based on the cost of the foreign keys. It is perfectly possible to have several shortest paths (if several paths have the same total cost). If there are several shortest paths, rather than choosing one path amongst the others, SchemaAnalyzer will throw a ShortestPathAmbiguityException. The exception message details all the possible shortest paths.

Caching results

Analyzing the full data model and looking for shortest paths can take a long time. For anything that should run in a production environment, it is recommended to cache the result. SchemaAnalyzer can be passed a Doctrine cache, along a cache prefix. The cache prefix is a string that will be used to prefix all cache keys. It is useful to avoid cache collisions between several databases.

Usage:

Changing the cost of the foreign keys to alter the shortest path

If you are facing an ambiguity exception or if the shortest path simply does not suit you, you can alter the cost of the foreign keys.

The $cost can be any number. Remember that the default cost for a foreign key is 1.

SchemaAnalyzer comes with a set of default constants to help you work with costs:

Another option is to add a cost modifier to a table. This will alter the cost of all foreign keys pointing to or originating from this table.


All versions of schema-analyzer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
clue/graph Version ~0.9.0
doctrine/dbal Version ^3.0
doctrine/cache Version ^1.4.1
graphp/algorithms Version ~0.8.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 mouf/schema-analyzer contains the following files

Loading the files please wait ....