我正在将一个Laravel barebone项目部署到Microsoft Azure,但每当我try 执行php artisan migrate时,就会出现错误:

[2015-06-13 14:34:05]生产.错误:异常"Symfony\Component\Debug\exception\FatalErrorException",在D:\home\site\vendor\laravel\framework\src\light\Database\Migrations\Migrator中显示消息"Class""not found".菲律宾:328

堆栈跟踪:

 #0 {main}  

有什么问题吗?非常感谢你

--编辑--

Migration Class

<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function(Blueprint $table)
        {
            $table->bigIncrements('id');
            $table->string('name', 50);
            $table->string('surname', 50);
            $table->bigInteger('telephone');
            $table->string('email', 50)->unique();
            $table->string('username', 50)->unique();
            $table->string('password', 50);
            $table->boolean('active')->default(FALSE);
            $table->string('email_confirmation_code', 6);
            $table->enum('notify', ['y', 'n'])->default('y');
            $table->rememberToken();
            $table->timestamps();
            
            $table->index('username');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }
}

推荐答案

For PSR-4 Auto Loader Users (composer.json):

将迁移文件夹放在classmap数组中,不要将其包含在autoload头以下的PSR-4对象中.因为迁移的主类Migrator不支持命名空间.例如:

"autoload": {
    "classmap": [
        "app/database/migrations"
    ],
    "psr-4": {
        "Acme\\controllers\\": "app/controllers"
    }
}

然后运行:

php artisan clear-compiled 
php artisan optimize:clear
composer dump-autoload
php artisan optimize
  • 第一个清除所有编译的自动加载文件.
  • 第二步清除Laravel缓存(可选)
  • 第三,为命名空间类构建自动加载器.
  • 第四,优化Laravel应用程序的各个部分,并为无名称空间的类构建自动加载程序.

从现在起,您将不必再这样做,任何新的迁移都将正常工作.

Php相关问答推荐

PHP FFI—将PHP数组转换为C指针数组

在WooCommerce我的帐户部分添加带有自定义链接的自定义菜单项

PHP MySQL求和子树并与父树累加

在Symfony 6.4中将工作流动态添加到服务

筛选器具有多个查询之一

针对给定产品类别的WooCommerce计数审核

PHP文件上载问题-";Move_Uploaded_Files";未按预期工作

使用简码在 WooCommerce 我的帐户中显示一些用户数据

Woocommerce API - 图像问题

如何将不同的 Woocommerce 费用合并为一个名称?

在php中计算两个没有假期的日期之间的小时差

PHP 在数组中搜索值

无法使用 slim 的父级容器

当所有对象都属于同一类型时,我可以省略 PHP in_array() 中的 strict 参数吗?

PHP - 计算非数值数组

Composer自动加载器重复了子类的类文件路径

根据购买产品的自定义字段替换WooCommerce添加到购物车按钮

在WooCommerce购物车和 checkout 页面中更改总计文本

如果有很多重定向,PHP curl 的行为不像命令行 curl

在 EasyAdmin 中添加全局操作,将我的按钮放在表格下方而不是上方