Download the PHP package stidges/laravel-fk-migration without Composer

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

Laravel FK Migration

Latest Stable Version Total Downloads Build Status License

This Laravel package provides a base migration for you to extend to easily create all your foreign keys. If you ever ran into the problem where you had to reorganize all your migrations due to failing foreign key constraints, this is the package for you!

Getting Started

This package can be installed through Composer, just add it to your composer.json file:

After you have added it to your composer.json file, make sure you update your dependencies:

Basic Usage

To get started, create a new class in your app/database/migrations/ directory. If you want to make sure this migration gets executed last, you can name it something like 9999_99_99_999999_create_foreign_keys.php (this might be slightly overdone, but you get the idea).

Next, add the following content to the empty class you just created:

The $keys array is where you can define your foreign keys. It should be an associative array, where the key is the table name, and the value is a (list of) foreign key(s). Below you can find a list of options that can be specified for the foreign keys.

Key Default Description
column none The column on which to create the foreign key.
references 'id' The referenced column in the foreign table.
on none The referenced table. If this option is not passed then it will create the name from the passed column (e.g. 'user_id' becomes 'users')
onUpdate 'cascade' The referential action to execute when the referenced column is updated.
onDelete 'restrict' The referential action to execute when the referenced column is deleted.

Note: As a minimum you should specify the column property for each foreign key. If you forget to specify this, an exception will be thrown.

Basic Example

Below you can find a basic example for reference.

Extended Example

Internally, the migration will call a getKeys() method, which by default returns the specified $keys array. You are free to override this method if you wish to have more flexibility when defining keys. For example, if you have a lot of tables referencing the users table, you can do the following:

This way you don't have to copy the same foreign key reference over and over!

Contributing

All suggestions and pull requests are welcome! If you make any substantial changes, please provide tests along with your pull requests!

License

Copyright (c) 2014 Stidges - Released under the MIT license.


All versions of laravel-fk-migration with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/database Version ~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 stidges/laravel-fk-migration contains the following files

Loading the files please wait ....