bootstrap/app.phpでvendor/laravel/framework/src/Illuminate/Foundation/Application.phpクラスをインスタンス化します
1 2 3 4 5 6 7 8 9 10 11 |
$app = new Illuminate\Foundation\Application( realpath (__DIR__. '/../' )
);
|
ログイン後にコピー
このクラスのマジックメソッド
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public function __construct( $basePath = null)
{
if ( $basePath ) { $this ->setBasePath( $basePath );
}
$this ->registerBaseBindings();
$this ->registerBaseServiceProviders();
$this ->registerCoreContainerAliases();
}
|
ログイン後にコピー
登録されたアプリを表示し、コンテナー インスタンス配列内
1 2 3 4 5 6 7 | protected function registerBaseBindings()
{ static ::setInstance( $this );
$this ->instance( 'app' , $this );
$this ->instance(Container:: class , $this );
}
|
ログイン後にコピー
今日のメインメソッドインスタンスを表示

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public function instance( $abstract , $instance )
{
$this ->removeAbstractAlias( $abstract );
$isBound = $this ->bound( $abstract );
unset( $this ->aliases[ $abstract ]);
$this ->instances[ $abstract ] = $instance ;
if ( $isBound ) { $this ->rebound( $abstract );
}
}
|
ログイン後にコピー
最初のメソッドremoveAbstractAlias
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
protected function removeAbstractAlias( $searched )
{
if (! isset( $this ->aliases[ $searched ])) { return ;
}
foreach ( $this ->abstractAliases as $abstract => $aliases ) { foreach ( $aliases as $index => $alias ) { if ( $alias == $searched ) { unset( $this ->abstractAliases[ $abstract ][ $index ]);
}
}
}
}
|
ログイン後にコピー
2番目の方法:バウンド
1 2 3 4 5 6 7 8 |
public function bound( $abstract )
{ return isset( $this ->bindings[ $abstract ]) || isset( $this ->instances[ $abstract ]) || $this ->isAlias( $abstract );
}
|
ログイン後にコピー
3番目の方法:リバウンド
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
protected function rebound( $abstract )
{
$instance = $this ->make( $abstract );
foreach ( $this ->getReboundCallbacks( $abstract ) as $callback ) { call_user_func( $callback , $this , $instance );
}
}
|
ログイン後にコピー
以上がLaravel 5.5) プロセスインスタンスメソッドのロードの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。