diff --git a/.devcontainer/config/app/.env.example b/.devcontainer/config/app/.env.example index 96f53b3c..97c8f6d4 100644 --- a/.devcontainer/config/app/.env.example +++ b/.devcontainer/config/app/.env.example @@ -17,5 +17,3 @@ AUTH_SALT='generateme' SECURE_AUTH_SALT='generateme' LOGGED_IN_SALT='generateme' NONCE_SALT='generateme' - -ACORN_ENABLE_EXPERIMENTAL_ROUTER='true' diff --git a/README.md b/README.md index 4fc1b60d..c959a9d4 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Acorn is a framework for integrating Laravel within WordPress. | illuminate/filesystem | 🟢 | | | illuminate/http | 🟢 | | | illuminate/log | 🟢 | | -| illuminate/routing | 🟡 | Requires `ACORN_ENABLE_EXPERIMENTAL_ROUTER` env var | +| illuminate/routing | 🟢 | | | illuminate/support | 🟢 | | | illuminate/view | 🟢 | | diff --git a/composer.json b/composer.json index e492f27b..020ba092 100644 --- a/composer.json +++ b/composer.json @@ -57,6 +57,7 @@ "illuminate/support": "^10.33", "illuminate/view": "^10.33", "laravel/prompts": "^0.1.7", + "laravel/serializable-closure": "^1.3", "league/flysystem": "^3.8", "ramsey/uuid": "^4.7", "roots/support": "^1.0", diff --git a/src/Roots/Acorn/Application.php b/src/Roots/Acorn/Application.php index 68006172..2412333b 100644 --- a/src/Roots/Acorn/Application.php +++ b/src/Roots/Acorn/Application.php @@ -8,7 +8,6 @@ use Illuminate\Foundation\PackageManifest as FoundationPackageManifest; use Illuminate\Foundation\ProviderRepository; use Illuminate\Support\Collection; -use Illuminate\Support\Env; use Illuminate\Support\ServiceProvider; use Roots\Acorn\Exceptions\SkipProviderException; use Roots\Acorn\Filesystem\Filesystem; @@ -378,10 +377,4 @@ public function version() { return 'Acorn '.static::VERSION.' (Laravel '.parent::VERSION.')'; } - - public static function isExperimentalRouterEnabled() - { - return Env::get('ACORN_ENABLE_EXPERIMENTAL_ROUTER', false) - || Env::get('ACORN_ENABLE_EXPIRIMENTAL_ROUTER', false); - } } diff --git a/src/Roots/Acorn/Bootloader.php b/src/Roots/Acorn/Bootloader.php index f33315a1..3009d196 100644 --- a/src/Roots/Acorn/Bootloader.php +++ b/src/Roots/Acorn/Bootloader.php @@ -114,16 +114,7 @@ public function boot($callback = null) return class_exists('WP_CLI') ? $this->bootWpCli($app) : $this->bootConsole($app); } - if (Application::isExperimentalRouterEnabled()) { - $app->singleton( - \Illuminate\Contracts\Http\Kernel::class, - \Roots\Acorn\Http\Kernel::class - ); - - return $this->bootHttp($app); - } - - return $this->bootWordPress($app); + return $this->bootHttp($app); } /** @@ -246,17 +237,6 @@ protected function bootHttp(ApplicationContract $app) }); } - /** - * Boot the Application for WordPress requests. - * - * @return void - */ - protected function bootWordPress(ApplicationContract $app) - { - $app->make(\Illuminate\Contracts\Http\Kernel::class) - ->handle(\Illuminate\Http\Request::capture()); - } - /** * Get Application instance. * @@ -268,7 +248,7 @@ public function getApplication(): ApplicationContract $this->app->singleton( \Illuminate\Contracts\Http\Kernel::class, - \Roots\Acorn\Kernel::class + \Roots\Acorn\Http\Kernel::class ); $this->app->singleton( diff --git a/src/Roots/Acorn/Console/Commands/RouteCacheCommand.php b/src/Roots/Acorn/Console/Commands/RouteCacheCommand.php index 563333b7..a4238258 100644 --- a/src/Roots/Acorn/Console/Commands/RouteCacheCommand.php +++ b/src/Roots/Acorn/Console/Commands/RouteCacheCommand.php @@ -3,13 +3,7 @@ namespace Roots\Acorn\Console\Commands; use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract; -use Illuminate\Filesystem\Filesystem; -use Roots\Acorn\Application; use Roots\Acorn\Console\Concerns\GetsFreshApplication; -use Roots\Acorn\Console\Console; -use Symfony\Component\Process\Exception\ProcessSignaledException; -use Symfony\Component\Process\Exception\RuntimeException; -use Symfony\Component\Process\Process; class RouteCacheCommand extends \Illuminate\Foundation\Console\RouteCacheCommand { @@ -17,94 +11,6 @@ class RouteCacheCommand extends \Illuminate\Foundation\Console\RouteCacheCommand getFreshApplication as protected parentGetFreshApplication; } - protected $console; - - public function __construct(Filesystem $files, Console $console) - { - parent::__construct($files); - - $this->console = $console; - } - - /** - * Execute the console command. - * - * @return void - */ - public function handle() - { - if (! Application::isExperimentalRouterEnabled()) { - return; - } - - if (! $this->ensureDependenciesExist()) { - return; - } - - parent::handle(); - } - - /** - * Ensure the dependencies for the database commands are available. - * - * @return bool - */ - protected function ensureDependenciesExist() - { - if (class_exists(\Laravel\SerializableClosure\SerializableClosure::class)) { - return true; - } - - $message = 'Route caching requires Serializable Closure (laravel/serializable-closure) package.'; - - if ($this->components->confirm("{$message} Would you like to install it?")) { - $this->installDependencies(); - if ($this->console->acorn('route:cache') === 0) { - $this->components->info('Routes cached successfully.'); - } - } else { - $this->components->error($message); - } - - return false; - } - - /** - * Install the command's dependencies. - * - * @return void - * - * @throws \Symfony\Component\Process\Exception\ProcessSignaledException - * - * @copyright Taylor Otwell - * - * @link https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Console/DatabaseInspectionCommand.php - */ - protected function installDependencies() - { - $command = collect($this->console->findComposer()) - ->push('require laravel/serializable-closure') - ->implode(' '); - - $process = Process::fromShellCommandline($command, null, null, null, null); - - if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { - try { - $process->setTty(true); - } catch (RuntimeException $e) { - $this->components->warn($e->getMessage()); - } - } - - try { - $process->run(fn ($type, $line) => $this->output->write($line)); - } catch (ProcessSignaledException $e) { - if (extension_loaded('pcntl') && $e->getSignal() !== SIGINT) { - throw $e; - } - } - } - /** * Get a fresh application instance. * diff --git a/src/Roots/Acorn/Kernel.php b/src/Roots/Acorn/Kernel.php deleted file mode 100644 index dbf9a4d2..00000000 --- a/src/Roots/Acorn/Kernel.php +++ /dev/null @@ -1,111 +0,0 @@ -app = $app; - } - - /** - * Bootstrap the application for HTTP requests. - * - * @return void - */ - public function bootstrap() - { - if (! $this->app->hasBeenBootstrapped()) { - $this->app->bootstrapWith($this->bootstrappers()); - } - } - - /** - * Handle an incoming HTTP request. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function handle($request) - { - $this->app->instance('request', $request); - - Facade::clearResolvedInstance('request'); - - $this->bootstrap(); - } - - /** - * Call the terminate method on any terminable middleware. - * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Http\Response $response - * @return void - */ - public function terminate($request, $response) - { - //... - } - - /** - * Get the bootstrap classes for the application. - * - * @return array - */ - protected function bootstrappers() - { - return $this->bootstrappers; - } - - /** - * Get the Laravel application instance. - * - * @return \Illuminate\Contracts\Foundation\Application - */ - public function getApplication() - { - return $this->app; - } - - /** - * Set the Laravel application instance. - * - * @return $this - */ - public function setApplication(Application $app) - { - $this->app = $app; - - return $this; - } -}