davedevelopment / phpmig

Simple migrations system for php
Other
568 stars 93 forks source link

ability to access service locator? #87

Closed Zxurian closed 9 years ago

Zxurian commented 9 years ago

I see that the readme uses Zend's autoloader. Is there any way to have access to the servicelocator from within the up() and down() methods?

davedevelopment commented 9 years ago

You can get access to anything you want really, the ArrayAccess return value of the phpmig.php bootstrap file is made available within the migrations.

// phpmig.php

$container = [];

// get service locator

$container['sl'] = $serviceLocator;

return $container;

// migration file

public function up()
{
    $this->get('sl')->foo();
}