ed-fruty / laravel4-namespace-migrator by ed-fruty

Package for Laravel 4, supporting using namespaces in migration classes
26
2
2
Package Data
Maintainer Username: ed-fruty
Maintainer Contact: ed.fruty@gmail.com (Eduard)
Package Create Date: 2014-12-02
Package Last Update: 2014-12-03
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-17 03:01:42
Package Statistics
Total Downloads: 26
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

laravel4-namespace-migrator

Laravel 4 is not support namespaces in migration classes, but it is not a problem ;)

#Installation

  1. Use Composer to install package into your project:
composer require "ed-fruty/laravel4-namespace-migrator": "1.0.0"
  1. Add the service provider in app/config/app.php:
'Fruty\LaravelNamespaceMigrator\LaravelNamespaceMigratorServiceProvider',
  1. Publish package configuration
php artisan config:publish ed-fruty/laravel4-namespace-migrator

#Usage

'reserved' => [
      base_path('app/modules/Blog/migrations') => 'Blog\\Migrations\\',
  ]

It means, when you call migrations like:

php artisan migrate --path=app/modules/Blog/migrations

Migrator automatically searches classes with namespace Blog\Migrations in that directory.

php artisan migrate --bench=foo/bar

Migrator searches classes with namespace Foo\Bar\Migrations in workbench/foo/bar/src/migrations So if workbench namespace does not equal to vendor/package name you must register it in 'reserved' block like:

base_path('workbench/foo/bar/src/migrations') => 'VendorNamespace\\PackageNamespace\\'
php artisan migrate

By default configs, Migrator firstly searches migration classes with namespace App\database\migrations in app/database/migrations and if it does not exists, Migrator tries to load class without namespace from that catalog.