Skip to content

Commit

Permalink
🚩 remove experimental flag (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t authored Dec 23, 2023
1 parent 3b9d58f commit 735cb59
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 237 deletions.
2 changes: 0 additions & 2 deletions .devcontainer/config/app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'

ACORN_ENABLE_EXPERIMENTAL_ROUTER='true'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 🟢 | |

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 0 additions & 7 deletions src/Roots/Acorn/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
24 changes: 2 additions & 22 deletions src/Roots/Acorn/Bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -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(
Expand Down
94 changes: 0 additions & 94 deletions src/Roots/Acorn/Console/Commands/RouteCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,108 +3,14 @@
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
{
use GetsFreshApplication {
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.
*
Expand Down
111 changes: 0 additions & 111 deletions src/Roots/Acorn/Kernel.php

This file was deleted.

0 comments on commit 735cb59

Please sign in to comment.