From 2502f0d78da860e44433264f65c119f6841f7a25 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:20:25 -0300 Subject: [PATCH 1/9] Tweaks the install command --- src/Commands/TurboInstallCommand.php | 131 ++++++--------------------- 1 file changed, 29 insertions(+), 102 deletions(-) diff --git a/src/Commands/TurboInstallCommand.php b/src/Commands/TurboInstallCommand.php index 6d63053..9f2ea36 100644 --- a/src/Commands/TurboInstallCommand.php +++ b/src/Commands/TurboInstallCommand.php @@ -4,10 +4,9 @@ use Illuminate\Console\Command; use Illuminate\Pipeline\Pipeline; -use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Process as ProcessFacade; use RuntimeException; -use Symfony\Component\Console\Terminal; use Symfony\Component\Process\Process; class TurboInstallCommand extends Command @@ -19,41 +18,32 @@ class TurboInstallCommand extends Command public $description = 'Installs Turbo.'; - private $afterMessages = []; - public function handle() { - $this->displayHeader('Installing Turbo Laravel', ' INFO '); - $this->updateTemplates(); + $this->updateLayouts(); $this->publishJsFiles(); $this->installJsDependencies(); - $this->displayAfterNotes(); - $this->newLine(); - $this->line(' Done!'); + $this->components->info('Turbo Laravel was installed successfully.'); } private function publishJsFiles() { - $this->displayTask('updating JS files', function () { - File::ensureDirectoryExists(resource_path('js/elements')); - File::ensureDirectoryExists(resource_path('js/libs')); + File::ensureDirectoryExists(resource_path('js/elements')); + File::ensureDirectoryExists(resource_path('js/libs')); - File::copy(__DIR__.'/../../stubs/resources/js/libs/turbo.js', resource_path('js/libs/turbo.js')); - File::copy(__DIR__.'/../../stubs/resources/js/elements/turbo-echo-stream-tag.js', resource_path('js/elements/turbo-echo-stream-tag.js')); + File::copy(__DIR__.'/../../stubs/resources/js/libs/turbo.js', resource_path('js/libs/turbo.js')); + File::copy(__DIR__.'/../../stubs/resources/js/elements/turbo-echo-stream-tag.js', resource_path('js/elements/turbo-echo-stream-tag.js')); - if ($this->option('jet')) { - File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine-jet.js', resource_path('js/libs/alpine.js')); - } elseif ($this->option('alpine')) { - File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine.js', resource_path('js/libs/alpine.js')); - } - - File::put(resource_path('js/app.js'), $this->appJsImportLines()); - File::put(resource_path('js/libs/index.js'), $this->libsIndexJsImportLines()); + if ($this->option('jet')) { + File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine-jet.js', resource_path('js/libs/alpine.js')); + } elseif ($this->option('alpine')) { + File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine.js', resource_path('js/libs/alpine.js')); + } - return self::SUCCESS; - }); + File::put(resource_path('js/app.js'), $this->appJsImportLines()); + File::put(resource_path('js/libs/index.js'), $this->libsIndexJsImportLines()); } private function appJsImportLines() @@ -98,14 +88,8 @@ private function installJsDependencies() private function updateNpmDependencies(): void { - $this->displayTask('updating NPM dependencies', function () { - $this->afterMessages[] = 'Run: `npm install && npm run build`'; - - $this->updateNodePackages(function ($packages) { - return $this->jsDependencies() + $packages; - }); - - return self::SUCCESS; + $this->updateNodePackages(function ($packages) { + return $this->jsDependencies() + $packages; }); } @@ -139,11 +123,13 @@ private function runCommands($commands): void private function updateImportmapsDependencies(): void { - $this->displayTask('pinning JS dependencies (Importmap)', function () { - $dependencies = array_keys($this->jsDependencies()); + $dependencies = array_keys($this->jsDependencies()); - return Artisan::call('importmap:pin '.implode(' ', $dependencies)); - }); + ProcessFacade::forever()->run(array_merge([ + $this->phpBinary(), + 'artisan', + 'importmap:pin', + ], $dependencies), fn ($_type, $output) => $this->output->write($output)); } private function jsDependencies(): array @@ -171,19 +157,6 @@ private function usingImportmaps(): bool return File::exists(base_path('routes/importmap.php')); } - private function updateTemplates(): void - { - $this->displayTask('updating templates', function () { - $this->updateLayouts(); - - return self::SUCCESS; - }); - } - - /** - * @param bool $dev - * @return void - */ protected static function updateNodePackages(callable $callback, $dev = true) { if (! File::exists(base_path('package.json'))) { @@ -209,59 +182,13 @@ protected static function updateNodePackages(callable $callback, $dev = true) private function updateLayouts(): void { - $this->existingLayoutFiles() - ->each( - fn ($file) => (new Pipeline(app())) - ->send($file) - ->through(array_filter([ - $this->option('jet') ? Tasks\EnsureLivewireTurboBridgeExists::class : null, - Tasks\EnsureCsrfTokenMetaTagExists::class, - ])) - ->thenReturn() - ); - - if ($this->option('jet')) { - $this->afterMessages[] = 'Ensured the Livewire/Turbo bridge was added to your layout files.'; - $this->afterMessages[] = 'Ensured the Livewire scripts and styles were added to your `guest` layout.'; - } - - $this->afterMessages[] = 'Ensured a CSRF Token meta tag exists in your layout files.'; - } - - private function displayHeader($text, $prefix) - { - $this->newLine(); - $this->line(sprintf(' %s %s ', $prefix, $text)); - $this->newLine(); - } - - private function displayTask($description, $task) - { - $width = (new Terminal())->getWidth(); - $dots = max(str_repeat('.', $width - strlen($description) - 13), 0); - $this->output->write(sprintf(' %s %s ', $description, $dots)); - $output = $task(); - - if ($output === self::SUCCESS) { - $this->output->write('DONE'); - } elseif ($output === self::FAILURE) { - $this->output->write('FAIL'); - } elseif ($output === self::INVALID) { - $this->output->write('WARN'); - } - - $this->newLine(); - } - - private function displayAfterNotes() - { - if (count($this->afterMessages) > 0) { - $this->displayHeader('After Notes & Next Steps', ' NOTES '); - - foreach ($this->afterMessages as $message) { - $this->line(' '.$message); - } - } + $this->existingLayoutFiles()->each(fn ($file) => (new Pipeline(app())) + ->send($file) + ->through(array_filter([ + $this->option('jet') ? Tasks\EnsureLivewireTurboBridgeExists::class : null, + Tasks\EnsureCsrfTokenMetaTagExists::class, + ])) + ->thenReturn()); } private function existingLayoutFiles() From 2c1c7c5d5fa896c975b9bcf077b71cc0b7dae8af Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:21:32 -0300 Subject: [PATCH 2/9] Remove livewire installer task --- .../Tasks/EnsureLivewireTurboBridgeExists.php | 46 ------------------- src/Commands/TurboInstallCommand.php | 1 - 2 files changed, 47 deletions(-) delete mode 100644 src/Commands/Tasks/EnsureLivewireTurboBridgeExists.php diff --git a/src/Commands/Tasks/EnsureLivewireTurboBridgeExists.php b/src/Commands/Tasks/EnsureLivewireTurboBridgeExists.php deleted file mode 100644 index 9f9a682..0000000 --- a/src/Commands/Tasks/EnsureLivewireTurboBridgeExists.php +++ /dev/null @@ -1,46 +0,0 @@ -', ''])) { - $fileContents = preg_replace( - '/(\s*)(<\/head>)/', - "\\1 @livewireStyles\n\\1\\2", - $fileContents, - ); - } - - if (! Str::contains($fileContents, ['@livewireScripts', '', ''])) { - $fileContents = preg_replace( - '/(\s*)(<\/body>)/', - "\\1 @livewireScripts\n\\1\\2", - $fileContents, - ); - } - - if (! Str::contains($fileContents, ['livewire-turbolinks.js'])) { - $fileContents = preg_replace( - '/(\s*)(<\/body>)/', - "\\1 \n\\1\\2", - $fileContents, - ); - } - - File::put($file, $fileContents); - - return $next($file); - } -} diff --git a/src/Commands/TurboInstallCommand.php b/src/Commands/TurboInstallCommand.php index 9f2ea36..f5efad9 100644 --- a/src/Commands/TurboInstallCommand.php +++ b/src/Commands/TurboInstallCommand.php @@ -185,7 +185,6 @@ private function updateLayouts(): void $this->existingLayoutFiles()->each(fn ($file) => (new Pipeline(app())) ->send($file) ->through(array_filter([ - $this->option('jet') ? Tasks\EnsureLivewireTurboBridgeExists::class : null, Tasks\EnsureCsrfTokenMetaTagExists::class, ])) ->thenReturn()); From dc810a404e8c49d0a8160871da0e6c8abf4e319a Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:30:24 -0300 Subject: [PATCH 3/9] Remove alpine stuff --- src/Commands/TurboInstallCommand.php | 34 ++++++--------------------- stubs/resources/js/libs/alpine-jet.js | 27 --------------------- stubs/resources/js/libs/alpine.js | 24 ------------------- 3 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 stubs/resources/js/libs/alpine-jet.js delete mode 100644 stubs/resources/js/libs/alpine.js diff --git a/src/Commands/TurboInstallCommand.php b/src/Commands/TurboInstallCommand.php index f5efad9..a61d7ee 100644 --- a/src/Commands/TurboInstallCommand.php +++ b/src/Commands/TurboInstallCommand.php @@ -7,14 +7,12 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Process as ProcessFacade; use RuntimeException; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; class TurboInstallCommand extends Command { - public $signature = 'turbo:install - {--alpine : To add Alpine as a JS dependency.} - {--jet : To update the Jetstream templates.} - '; + public $signature = 'turbo:install'; public $description = 'Installs Turbo.'; @@ -36,12 +34,6 @@ private function publishJsFiles() File::copy(__DIR__.'/../../stubs/resources/js/libs/turbo.js', resource_path('js/libs/turbo.js')); File::copy(__DIR__.'/../../stubs/resources/js/elements/turbo-echo-stream-tag.js', resource_path('js/elements/turbo-echo-stream-tag.js')); - if ($this->option('jet')) { - File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine-jet.js', resource_path('js/libs/alpine.js')); - } elseif ($this->option('alpine')) { - File::copy(__DIR__.'/../../stubs/resources/js/libs/alpine.js', resource_path('js/libs/alpine.js')); - } - File::put(resource_path('js/app.js'), $this->appJsImportLines()); File::put(resource_path('js/libs/index.js'), $this->libsIndexJsImportLines()); } @@ -67,12 +59,6 @@ private function libsIndexJsImportLines() ? "import 'libs/turbo';" : "import './turbo';"; - if ($this->option('alpine') || $this->option('jet')) { - $imports[] = $this->usingImportmaps() - ? "import 'libs/alpine';" - : "import './alpine';"; - } - return implode("\n", $imports); } @@ -138,17 +124,6 @@ private function jsDependencies(): array '@hotwired/turbo' => '^8.0.0-beta.1', 'laravel-echo' => '^1.15.0', 'pusher-js' => '^8.0.1', - ] + $this->alpineDependencies(); - } - - private function alpineDependencies(): array - { - if (! $this->option('alpine') && ! $this->option('jet')) { - return []; - } - - return [ - 'alpinejs' => '^3.11.1', ]; } @@ -196,4 +171,9 @@ private function existingLayoutFiles() ->map(fn ($file) => resource_path("views/layouts/{$file}.blade.php")) ->filter(fn ($file) => File::exists($file)); } + + private function phpBinary() + { + return (new PhpExecutableFinder())->find(false) ?: 'php'; + } } diff --git a/stubs/resources/js/libs/alpine-jet.js b/stubs/resources/js/libs/alpine-jet.js deleted file mode 100644 index 1485d43..0000000 --- a/stubs/resources/js/libs/alpine-jet.js +++ /dev/null @@ -1,27 +0,0 @@ -import Alpine from 'alpinejs'; -import focus from '@alpinejs/focus'; - -window.Alpine = Alpine; - -Alpine.plugin(focus); - -Alpine.start(); - -function initAlpineTurboPermanentFix() { - document.addEventListener('turbo:before-render', () => { - let permanents = document.querySelectorAll('[data-turbo-permanent]'); - let undos = Array.from(permanents).map(el => { - el._x_ignore = true; - return () => { - delete el._x_ignore; - }; - }); - - document.addEventListener('turbo:render', function handler() { - while(undos.length) undos.shift()(); - document.removeEventListener('turbo:render', handler); - }); - }); -} - -initAlpineTurboPermanentFix(); diff --git a/stubs/resources/js/libs/alpine.js b/stubs/resources/js/libs/alpine.js deleted file mode 100644 index d98e1a0..0000000 --- a/stubs/resources/js/libs/alpine.js +++ /dev/null @@ -1,24 +0,0 @@ -import Alpine from 'alpinejs'; - -window.Alpine = Alpine; - -Alpine.start(); - -function initAlpineTurboPermanentFix() { - document.addEventListener('turbo:before-render', () => { - let permanents = document.querySelectorAll('[data-turbo-permanent]'); - let undos = Array.from(permanents).map(el => { - el._x_ignore = true; - return () => { - delete el._x_ignore; - }; - }); - - document.addEventListener('turbo:render', function handler() { - while(undos.length) undos.shift()(); - document.removeEventListener('turbo:render', handler); - }); - }); -} - -initAlpineTurboPermanentFix(); From 0c3b4bd09aff6fc6d69b2708cd79328e409674e3 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:39:18 -0300 Subject: [PATCH 4/9] Tweaks versions and configure PHPUnit --- .github/workflows/run-tests.yml | 4 ++- .gitignore | 1 + composer.json | 8 +++--- phpunit.xml.dist | 39 +++++++++++--------------- tests/TurboStreamsBroadcastingTest.php | 19 ++++--------- 5 files changed, 31 insertions(+), 40 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 40ff459..fb0e373 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,11 +10,13 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] php: [8.2] - laravel: [10.*] + laravel: [10.*, 11.*] stability: [prefer-lowest, prefer-stable] include: - laravel: 10.* testbench: 8.* + - laravel: 11.* + testbench: 9.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 3b01ce5..d8dbda2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .php_cs.cache .php-cs-fixer.cache .phpunit.result.cache +.phpunit.cache build composer.lock coverage diff --git a/composer.json b/composer.json index 646ccce..185b075 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,13 @@ ], "require": { "php": "^8.2", - "illuminate/support": "^10.0" + "illuminate/support": "^10.0|^11.0" }, "require-dev": { "laravel/pint": "^1.10", - "orchestra/testbench": "^8.14", - "orchestra/workbench": "^1.0", - "phpunit/phpunit": "^9.6" + "orchestra/testbench": "^8.14|^9.0", + "orchestra/workbench": "^1.0|^8.3", + "phpunit/phpunit": "^10.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9da1247..955a15b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,29 @@ - tests - - - ./src - - - - - - - - + - + + + + ./src + + diff --git a/tests/TurboStreamsBroadcastingTest.php b/tests/TurboStreamsBroadcastingTest.php index e493750..127cf97 100644 --- a/tests/TurboStreamsBroadcastingTest.php +++ b/tests/TurboStreamsBroadcastingTest.php @@ -26,22 +26,15 @@ protected function setUp(): void TurboStream::fake(); } - public function turboStreamDefaultInsertActions() - { - return [ - ['append'], - ['prepend'], - ['before'], - ['after'], - ['update'], - ['replace'], - ]; - } - /** * @test * - * @dataProvider turboStreamDefaultInsertActions + * @testWith ["append"] + * ["prepend"] + * ["before"] + * ["after"] + * ["update"] + * ["replace"] */ public function can_manually_broadcast_append_streams(string $action) { From 59e12c9abd25a9c47d6301576afd9d78dcf87996 Mon Sep 17 00:00:00 2001 From: tonysm Date: Thu, 7 Mar 2024 00:39:49 +0000 Subject: [PATCH 5/9] Fix styling --- src/Broadcasters/Broadcaster.php | 14 +++++++------- src/Broadcasters/LaravelBroadcaster.php | 16 ++++++++-------- src/globals.php | 6 +++--- src/helpers.php | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Broadcasters/Broadcaster.php b/src/Broadcasters/Broadcaster.php index dacc0f4..e49340d 100644 --- a/src/Broadcasters/Broadcaster.php +++ b/src/Broadcasters/Broadcaster.php @@ -8,13 +8,13 @@ interface Broadcaster { /** * @param Channel[] $channels - * @param ?string $target = null - * @param ?string $targets = null - * @param ?string $partial = null - * @param ?array $partialData = [] - * @param ?string $inlineContent = null - * @param bool $escapeInlineContent = true - * @param ?string $exceptSocket = null + * @param ?string $target = null + * @param ?string $targets = null + * @param ?string $partial = null + * @param ?array $partialData = [] + * @param ?string $inlineContent = null + * @param bool $escapeInlineContent = true + * @param ?string $exceptSocket = null */ public function broadcast( array $channels, diff --git a/src/Broadcasters/LaravelBroadcaster.php b/src/Broadcasters/LaravelBroadcaster.php index 02102c3..1b5c40a 100644 --- a/src/Broadcasters/LaravelBroadcaster.php +++ b/src/Broadcasters/LaravelBroadcaster.php @@ -8,14 +8,14 @@ class LaravelBroadcaster implements Broadcaster { /** * @param \Illuminate\Broadcasting\Channel[] $channels - * @param ?string $target = null - * @param ?string $targets = null - * @param ?string $partial = null - * @param ?array $partialData = [] - * @param ?string $inlineContent = null - * @param bool $escapeInlineContent = true - * @param array $attributes = [] - * @param ?string $exceptSocket = null + * @param ?string $target = null + * @param ?string $targets = null + * @param ?string $partial = null + * @param ?array $partialData = [] + * @param ?string $inlineContent = null + * @param bool $escapeInlineContent = true + * @param array $attributes = [] + * @param ?string $exceptSocket = null */ public function broadcast( array $channels, diff --git a/src/globals.php b/src/globals.php index 399cae5..e64ebc7 100644 --- a/src/globals.php +++ b/src/globals.php @@ -36,8 +36,8 @@ function dom_class(object $model, string $prefix = ''): string /** * Builds the Turbo Streams. * - * @param Model|Collection|array|string|null $model = null - * @param string|null $action = null + * @param Model|Collection|array|string|null $model = null + * @param string|null $action = null */ function turbo_stream($model = null, ?string $action = null): MultiplePendingTurboStreamResponse|PendingTurboStreamResponse { @@ -50,7 +50,7 @@ function turbo_stream($model = null, ?string $action = null): MultiplePendingTur * Renders a Turbo Stream view wrapped with the correct Content-Types in the response. * * @param string|\Illuminate\View\View $view - * @param array $data = [] the binding params to be passed to the view. + * @param array $data = [] the binding params to be passed to the view. */ function turbo_stream_view($view, array $data = []): Response|ResponseFactory { diff --git a/src/helpers.php b/src/helpers.php index e876dc1..2470354 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -36,8 +36,8 @@ function dom_class(object $model, string $prefix = ''): string /** * Builds the Turbo Streams. * - * @param Model|Collection|array|string|null $model = null - * @param string|null $action = null + * @param Model|Collection|array|string|null $model = null + * @param string|null $action = null */ function turbo_stream($model = null, ?string $action = null): MultiplePendingTurboStreamResponse|PendingTurboStreamResponse { @@ -58,7 +58,7 @@ function turbo_stream($model = null, ?string $action = null): MultiplePendingTur * Renders a Turbo Stream view wrapped with the correct Content-Types in the response. * * @param string|\Illuminate\View\View $view - * @param array $data = [] the binding params to be passed to the view. + * @param array $data = [] the binding params to be passed to the view. */ function turbo_stream_view($view, array $data = []): Response|ResponseFactory { From c6c06aacfafccd8f3e5f5c7360781a3d900b4a09 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:45:31 -0300 Subject: [PATCH 6/9] Tweaks workbench versions --- .github/workflows/run-tests.yml | 4 +++- composer.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fb0e373..9891cbe 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,8 +15,10 @@ jobs: include: - laravel: 10.* testbench: 8.* + workbench: 8.* - laravel: 11.* testbench: 9.* + workbench: 9.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -38,7 +40,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:^2.64.1" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "orchestra/workbench:${{ matrix.workbench }}" "nesbot/carbon:^2.64.1" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests diff --git a/composer.json b/composer.json index 185b075..0b03c23 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "laravel/pint": "^1.10", "orchestra/testbench": "^8.14|^9.0", - "orchestra/workbench": "^1.0|^8.3", + "orchestra/workbench": "^8.0|^9.0", "phpunit/phpunit": "^10.5" }, "autoload": { From ad6369c6b76b5c8c87c71477a200ec22a66145d6 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:47:35 -0300 Subject: [PATCH 7/9] Install Turbo 8 --- src/Commands/TurboInstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/TurboInstallCommand.php b/src/Commands/TurboInstallCommand.php index a61d7ee..59e783a 100644 --- a/src/Commands/TurboInstallCommand.php +++ b/src/Commands/TurboInstallCommand.php @@ -121,7 +121,7 @@ private function updateImportmapsDependencies(): void private function jsDependencies(): array { return [ - '@hotwired/turbo' => '^8.0.0-beta.1', + '@hotwired/turbo' => '^8.0.3', 'laravel-echo' => '^1.15.0', 'pusher-js' => '^8.0.1', ]; From c8e1c68eeb9524a0b0f42ac95ce2a0646d7c57b0 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:53:26 -0300 Subject: [PATCH 8/9] Adds a x-turbo::page-view-transition meta component --- resources/views/components/page-view-transition.blade.php | 1 + tests/Views/ComponentsTest.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 resources/views/components/page-view-transition.blade.php diff --git a/resources/views/components/page-view-transition.blade.php b/resources/views/components/page-view-transition.blade.php new file mode 100644 index 0000000..25facd6 --- /dev/null +++ b/resources/views/components/page-view-transition.blade.php @@ -0,0 +1 @@ + diff --git a/tests/Views/ComponentsTest.php b/tests/Views/ComponentsTest.php index af5aa0c..2403bdf 100644 --- a/tests/Views/ComponentsTest.php +++ b/tests/Views/ComponentsTest.php @@ -213,9 +213,11 @@ public function turbo_drive_components() + BLADE) ->assertSee('', false) ->assertSee('', false) - ->assertSee('', false); + ->assertSee('', false) + ->assertSee('', false); } } From 3802ec1f4affe569e9dbc63a7513ed763d738fd5 Mon Sep 17 00:00:00 2001 From: Tony Messias Date: Wed, 6 Mar 2024 21:59:53 -0300 Subject: [PATCH 9/9] Tweaks docs --- docs/installation.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 02ef31a..326ce42 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -3,7 +3,7 @@ Turbo Laravel can be installed via [Composer](https://getcomposer.org/): ```bash -composer require hotwired-laravel/turbo-laravel:^2.0.0-beta1 +composer require hotwired-laravel/turbo-laravel:^2.0.0 ``` After installing the package, you may run the `turbo:install` Artisan command. This command will add the Turbo.js dependency to your `package.json` file (when you're using Vite and NPM) or to your `routes/importmap.php` file (when it detects that you're using [Importmap Laravel](https://github.com/tonysm/importmap-laravel)). It also publishes some files to your `resources/js` folder, which imports Turbo for you: @@ -12,16 +12,6 @@ After installing the package, you may run the `turbo:install` Artisan command. T php artisan turbo:install ``` -If you're using [Laravel Jetstream](https://jetstream.laravel.com/introduction.html) with [Livewire](https://livewire.laravel.com/), you may add the `--jet` flag to the `turbo:install` Artisan command. This flag will add some required JS dependencies to make sure [Alpine.js](https://alpinejs.dev/) works well with Turbo. It also changes the layout files that ships with Jetstream adding the [Livewire Turbo Plugin](https://github.com/livewire/turbolinks) to make sure Livewire works well with Turbo, too: - -```bash -php artisan turbo:install --jet -``` - -If you're using [Alpine.js](https://alpinejs.dev/) in a non-Jetstream context (maybe you're more into [Breeze](https://laravel.com/docs/starter-kits#laravel-breeze)), you may use the `--alpine` flag in the `turbo:install` Artisan command: - -```bash -php artisan turbo:install --alpine -``` +Note: Turbo used to work with Livewire, but somewhere around Livewire V3 the bridges stopped working. There's an open issue to investigate Livewire V3 compatibility. If you're into Livewire and would love to use Turbo in a Livewire app (maybe you want to augment your Livewire&Turbo app with Turbo Native or something like that), you're welcome to check out the issue and try to bring the compatibility back. If you wanted an application scaffolding like Laravel Breeze or Laravel Jetstream, checkout Turbo Breeze, our fork of Breeze that sets up a fresh Laravel app using Stimulus, Importmaps, TailwindCSS (via the CLI), and Turbo. [Continue to Overview...](/docs/{{version}}/overview)