我是在laravel中创建软件包的新手。我已经制作了一个调查包,并在内部包中制作了以下目录结构。
现在,我已从服务提供商处按如下方式加载文件,
SurveyServiceProvider.php
<?php
namespace Survey;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class SurveyServiceProvider extends ServiceProvider
{
public function boot()
{
Schema::defaultStringLength(191);
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
$this->loadMigrationsFrom(__DIR__.'/./../publishables/database/migrations');
$this->loadViewsFrom(__DIR__.'/./../resources/views/','survey');
}
public function register()
{
$this->registerPublishables();
}
private function registerPublishables()
{
$basePath = dirname(__DIR__);
$arrPublishable = [
'migrations' => [
"$basePath/publishables/database/migrations" => database_path('migrations'),
"$basePath/publishables/config/survey.php" => config_path('survey.php'),
]
];
foreach ($arrPublishable as $group => $paths) {
$this->publishes($paths,$group);
}
}
}
我的迁移文件是在vendor:publish
命令之后创建的
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAuditsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('audits', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->boolean('is_published');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('audits');
}
}
但是,当我执行php artisan migrate
审计迁移文件时,没有在那里执行任何原因。
还有一件事,我已经执行了composer dumpautoload
命令
请询问您是否需要更多详细信息。