gpt4 book ai didi

migration - Laravel 4 迁移 - 未找到类

转载 作者:行者123 更新时间:2023-12-02 21:45:17 25 4
gpt4 key购买 nike

这个问题现在已经解决了 - 我使用了以下内容:

而且,感谢 IRC,问题得到了解决。我被告知要跑

php composer.phar dump-autoload

这解决了我的问题。这可能与我奇怪的 Composer 设置有关。

<小时/>

我刚刚开始使用 Laravel 4 来完成一个 future 可能的项目,来自 Laravel 3。我首先使用 artisan 创建一个新的迁移 create_blogs_table:

php artisan migrate:make create_blogs_table --table=blogs --create

这生成了基本的迁移文件结构,然后我又填写了一些内容:

<?php

use Illuminate\Database\Migrations\Migration;

class CreateBlogsTable extends Migration
{

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('blogs', function($table)
{
$table->increments('id');
$table->string('title');
$table->text('description')->nullable();
$table->integer('user_id')->unsigned();
$table->timestamps();
});
}

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

我现在尝试再次使用 artisan 运行此迁移:

php artisan migrate --env=local

*注意我为扩展名为 .dev 的域设置了本地数据库连接

以前这可以正常工作(在 Laravel 3 中),但是使用 Illuminate 我会收到此错误:

PHP Fatal error:  Class 'CreateBlogsTable' not found in /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php on line 301
PHP Stack trace:
PHP 1. {main}() /var/www/gamingsite/artisan:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/gamingsite/artisan:57
PHP 3. Symfony\Component\Console\Application->doRun() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Application.php:106
PHP 4. Illuminate\Console\Command->run() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP 5. Symfony\Component\Console\Command\Command->run() /var/www/gamingsite/vendor/illuminate/console/src/Illuminate/Console/Command.php:95
PHP 6. Illuminate\Console\Command->execute() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:240
PHP 7. Illuminate\Database\Console\Migrations\MigrateCommand->fire() /var/www/gamingsite/vendor/illuminate/console/src/Illuminate/Console/Command.php:107
PHP 8. Illuminate\Database\Migrations\Migrator->run() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:69
PHP 9. Illuminate\Database\Migrations\Migrator->runMigrationList() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:75
PHP 10. Illuminate\Database\Migrations\Migrator->runUp() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:106
PHP 11. Illuminate\Database\Migrations\Migrator->resolve() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:125
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/gamingsite/app/start/../storage/logs/log-2012-12-28.txt" could not be opened: failed to open stream: Permission denied' in /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:71
Stack trace:
#0 /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(77): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)
#2 /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Logger.php(214): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#3 /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Logger.php(278): Monolog\Logger->addRecord(400, Object(Symfony\Component\HttpKernel\Exception\FatalErrorException), Array)
#4 [internal function]: Monolog\Logger->addError(Object(Symfony\Component\HttpKernel\Exception\FatalErrorExcepti in /var/www/gamingsite/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 71
PHP Stack trace:
PHP 1. {main}() /var/www/gamingsite/artisan:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/gamingsite/artisan:57
PHP 3. Symfony\Component\Console\Application->doRun() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Application.php:106
PHP 4. Illuminate\Console\Command->run() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP 5. Symfony\Component\Console\Command\Command->run() /var/www/gamingsite/vendor/illuminate/console/src/Illuminate/Console/Command.php:95
PHP 6. Illuminate\Console\Command->execute() /var/www/gamingsite/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:240
PHP 7. Illuminate\Database\Console\Migrations\MigrateCommand->fire() /var/www/gamingsite/vendor/illuminate/console/src/Illuminate/Console/Command.php:107
PHP 8. Illuminate\Database\Migrations\Migrator->run() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:69
PHP 9. Illuminate\Database\Migrations\Migrator->runMigrationList() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:75
PHP 10. Illuminate\Database\Migrations\Migrator->runUp() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:106
PHP 11. Illuminate\Database\Migrations\Migrator->resolve() /var/www/gamingsite/vendor/illuminate/database/src/Illuminate/Database/Migrations/Migrator.php:125

我已经检查过,database/migrations/文件夹肯定会自动加载。我不知道这个问题的原因可能是什么。在 IRC 上询问并在谷歌上搜索后,我仍然完全一无所知,所以希望有人可以帮助我。

提前致谢!

最佳答案

我在 xubuntu 上遇到了这个错误,并使用 sudo Composer dump-autoload 修复了它

关于migration - Laravel 4 迁移 - 未找到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com