【发布时间】:2014-06-11 14:33:58
【问题描述】:
我成功地命名了我的整个包,但我无法让命名空间迁移工作。在 autoload_classmap.php 中,迁移类的命名空间很好,但 Migrator 并没有在命名空间中寻找迁移类。如何让迁移器在命名空间内搜索迁移?
迁移文件
<?php namespace Atomend\Aeuser;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Schema, User;
class UsersTable extends Migration {
public function up() {
Schema::create("users", function(Blueprint $table) {
$table
->increments("id");
autoload_classmap.php
'Atomend\\Aeuser\\UsersTable' => $baseDir . '/src/migrations/2014_04_21_184359_users_table.php',
终端错误
PHP Fatal error: Class 'UsersTable' not found in
这是合乎逻辑的,因为 UsersTable 位于 Atomend\Aeuser 命名空间中。
发布迁移
php artisan migrate --bench="atomend/aeuser"`
所以要明确一点,当丢失命名空间时,一切正常且花花公子。
【问题讨论】:
-
您是如何创建迁移文件的?
-
能否包含执行迁移的命令?你的工作还在工作台上吗?
-
您尝试过使用
--path吗?php artisan migrate --path=app/foo/migrations -
您是否尝试在工作台根目录和 laravel 根文件夹上运行
composer dump-autoload? -
那不行,autoload_classmap.php也没有问题。正如您在示例代码中看到的那样,它位于正确的命名空间中。