Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.1] Overhauling the bootloader to be more flexible #541

Merged
merged 19 commits into from
Jun 12, 2024

Conversation

srtfisher
Copy link
Member

@srtfisher srtfisher commented May 3, 2024

Allow the bootloader to configure an application without any additional arguments. Also, allow the application to be configured through the bootloader. This will allow any application to truly use the framework's features with just:

bootloader()->boot();

Previously, this was a goal and worked but not exactly. The queue didn't work well without a kernel and some more configuration. All of this is now behind us and we can call the bootloader in another application and use the queue/database/etc.

With the changes in this PR we can simplify bootstrap/app.php to this:

return Bootloader::create()
	->with_kernels(
		console: App\Console\Kernel::class,
		http: App\Http\Kernel::class,
	)
	->with_exception_handler( App\Exceptions\Handler::class )
	->with_routing(
		web: __DIR__ . '/../routes/web.php',
		rest_api: __DIR__ . '/../routes/rest-api.php',
		pass_through: true,
	);

@srtfisher srtfisher changed the title Overhauling the bootloader to be more flexible [1.1] Overhauling the bootloader to be more flexible May 9, 2024
@srtfisher srtfisher marked this pull request as ready for review June 7, 2024 18:30
Copy link
Member

@attackant attackant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things for your review.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -28,8 +28,12 @@ class Model_Service_Provider extends Service_Provider {
* Register the service provider.
*/
public function register(): void {
Model::set_event_dispatcher( $this->app['events'] );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to leave this method empty now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

$dirname = basename( dirname( $file->getRealPath() ) );
$environment = match ( $dirname ) {
// Ignore the 'config' directory as an environment.
'config', 'configuration' => null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure, but do any of the changes for loading and merging configuration in this file have performance considerations we should think about?

* @param class-string<Contracts\Http\Kernel>|null $http HTTP kernel class.
*/
public function with_kernels( string $console = null, string $http = null ): static {
if ( $console && ! in_array( Contracts\Console\Kernel::class, class_implements( $console ), true ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a ! class_exists( $handler ) also make sense here? Or would this already be caught? Same question for with_exception_handler method below.

Co-authored-by: Damian <4309872+attackant@users.noreply.github.com>
@srtfisher srtfisher merged commit 5a5e10c into 1.x Jun 12, 2024
15 of 16 checks passed
@srtfisher srtfisher deleted the feature/flexible-bootloader branch June 12, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants