registeringPackage(); $this->package = $this->newPackage(); $this->package->setBasePath($this->getPackageBaseDir()); $this->configurePackage($this->package); if (empty($this->package->name)) { throw InvalidPackage::nameIsRequired(); } $this->registerPackageConfigs(); $this->packageRegistered(); return $this; } public function registeringPackage() { } public function newPackage(): Package { return new Package(); } public function packageRegistered() { } public function boot() { $this->bootingPackage(); $this ->bootPackageAssets() ->bootPackageBladeComponents() ->bootPackageCommands() ->bootPackageConsoleCommands() ->bootPackageConfigs() ->bootPackageInertia() ->bootPackageMigrations() ->bootPackageRoutes() ->bootPackageServiceProviders() ->bootPackageTranslations() ->bootPackageViews() ->bootPackageViewComposers() ->bootPackageViewSharedData() ->packageBooted(); return $this; } public function bootingPackage() { } public function packageBooted() { } protected function getPackageBaseDir(): string { $reflector = new ReflectionClass(get_class($this)); $packageBaseDir = dirname($reflector->getFileName()); // Some packages like to keep Laravels directory structure and place // the service providers in a Providers folder. // move up a level when this is the case. if (str_ends_with($packageBaseDir, DIRECTORY_SEPARATOR.'Providers')) { $packageBaseDir = dirname($packageBaseDir); } return $packageBaseDir; } public function packageView(?string $namespace): ?string { return is_null($namespace) ? $this->package->shortName() : $this->package->viewNamespace; } }