Php Laravel-$app上的分段错误->;make()
我在Laravel有一家服务提供商,看起来像这样:Php Laravel-$app上的分段错误->;make(),php,laravel,Php,Laravel,我在Laravel有一家服务提供商,看起来像这样: class ImportServiceProvider extends ServiceProvider { protected $importable = [ \MyApp\Agencies\AgencyImporter::class ]; /** * Register the application services. * * @return void */
class ImportServiceProvider extends ServiceProvider
{
protected $importable = [
\MyApp\Agencies\AgencyImporter::class
];
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->resolving(Importer::class, function (Importer $importer, $app) {
foreach($this->importable as $implementation) {
$importer->attach($app->make($implementation));
}
});
}
}
其思想是,在实例化Importer
类时,可以将许多对象作为观察者添加到该类中
但是,当我到达代码中的这一行时,我得到了一个分段错误
错误:
$app->make($implementation)
但是,如果我在闭包之前使用硬编码类运行代码,它可以正常工作:
$app->make(\MyApp\Agencies\AgencyImporter::class);
$this->app->resolving(Importer::class, function (Importer $importer, $app) {
foreach($this->importable as $implementation) {
//$importer->attach($app->make($implementation));
}
});
所以这似乎是关闭的问题。为什么会发生这种情况?您使用的是PHP5.x还是PHP7?几天前我在PHP上也遇到了分段错误7@MarcinNabiałek这是PHP5这是PHP7的问题。如您所见,这在新版本7.0.1-@psantosim中使用PHP5修复。6@dj完整的版本号?5.6.x(一些PHP5.6.x也有这个bug)