Skip to content

[2.x] Laravel v10 Support #1216

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

Merged
merged 16 commits into from
Jan 16, 2023
11 changes: 7 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ jobs:
fail-fast: true
matrix:
php: ['8.0', 8.1, 8.2]
laravel: [9.*]
laravel: [9, 10]
exclude:
- php: '8.0'
laravel: 10

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand All @@ -36,7 +39,7 @@ jobs:

- name: Install dependencies
run: |
composer require "illuminate/contracts=${{ matrix.laravel }}" --dev --no-update
composer require "illuminate/contracts=^${{ matrix.laravel }}" --dev --no-update
composer update --prefer-dist --no-interaction --no-progress

- name: Execute tests
Expand All @@ -56,15 +59,15 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none

- name: Setup Laravel
run: |
composer create-project laravel/laravel:^9 .
composer create-project laravel/laravel:10.x-dev .
composer require laravel/jetstream:* --no-interaction --no-update
composer config repositories.jetstream '{"type": "path", "url": "jetstream"}' --file composer.json

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"require": {
"php": "^8.0.2",
"ext-json": "*",
"illuminate/console": "^9.21",
"illuminate/support": "^9.21",
"illuminate/console": "^9.21|^10.0",
"illuminate/support": "^9.21|^10.0",
"jenssegers/agent": "^2.6",
"laravel/fortify": "^1.15"
},
"require-dev": {
"inertiajs/inertia-laravel": "^0.6.4",
"inertiajs/inertia-laravel": "^0.6.5",
"laravel/sanctum": "^3.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^7.0",
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.3"
},
"conflict": {
Expand Down
36 changes: 25 additions & 11 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,22 @@ public function handle()

// Install Stack...
if ($this->argument('stack') === 'livewire') {
$this->installLivewireStack();
if (! $this->installLivewireStack()) {
return 1;
}
} elseif ($this->argument('stack') === 'inertia') {
$this->installInertiaStack();
if (! $this->installInertiaStack()) {
return 1;
}
}

// Tests...
$stubs = $this->getTestStubsPath();

if ($this->option('pest')) {
$this->requireComposerDevPackages('pestphp/pest:^1.16', 'pestphp/pest-plugin-laravel:^1.1');
if ($this->requireComposerDevPackages('pestphp/pest:^1.16', 'pestphp/pest-plugin-laravel:^1.1')) {
return 1;
}

copy($stubs.'/Pest.php', base_path('tests/Pest.php'));
copy($stubs.'/ExampleTest.php', base_path('tests/Feature/ExampleTest.php'));
Expand Down Expand Up @@ -128,12 +134,14 @@ protected function configureSession()
/**
* Install the Livewire stack into the application.
*
* @return void
* @return bool
*/
protected function installLivewireStack()
{
// Install Livewire...
$this->requireComposerPackages('livewire/livewire:^2.5');
if (! $this->requireComposerPackages('livewire/livewire:^2.11')) {
return false;
}

// Sanctum...
(new Process([$this->phpBinary(), 'artisan', 'vendor:publish', '--provider=Laravel\Sanctum\SanctumServiceProvider', '--force'], base_path()))
Expand Down Expand Up @@ -252,6 +260,8 @@ protected function installLivewireStack()

$this->line('');
$this->components->info('Livewire scaffolding installed successfully.');

return true;
}

/**
Expand Down Expand Up @@ -306,12 +316,14 @@ protected function livewireRouteDefinition()
/**
* Install the Inertia stack into the application.
*
* @return void
* @return bool
*/
protected function installInertiaStack()
{
// Install Inertia...
$this->requireComposerPackages('inertiajs/inertia-laravel:^0.6.3', 'tightenco/ziggy:^1.0');
if (! $this->requireComposerPackages('inertiajs/inertia-laravel:^0.6.5', 'tightenco/ziggy:^1.0')) {
return false;
}

// Install NPM packages...
$this->updateNodePackages(function ($packages) {
Expand Down Expand Up @@ -448,6 +460,8 @@ protected function installInertiaStack()

$this->line('');
$this->components->info('Inertia scaffolding installed successfully.');

return true;
}

/**
Expand Down Expand Up @@ -619,7 +633,7 @@ protected function getTestStubsPath()
* Installs the given Composer Packages into the application.
*
* @param mixed $packages
* @return void
* @return bool
*/
protected function requireComposerPackages($packages)
{
Expand All @@ -634,7 +648,7 @@ protected function requireComposerPackages($packages)
is_array($packages) ? $packages : func_get_args()
);

(new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1']))
return ! (new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1']))
->setTimeout(null)
->run(function ($type, $output) {
$this->output->write($output);
Expand All @@ -645,7 +659,7 @@ protected function requireComposerPackages($packages)
* Install the given Composer Packages as "dev" dependencies.
*
* @param mixed $packages
* @return void
* @return bool
*/
protected function requireComposerDevPackages($packages)
{
Expand All @@ -660,7 +674,7 @@ protected function requireComposerDevPackages($packages)
is_array($packages) ? $packages : func_get_args()
);

(new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1']))
return ! (new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1']))
->setTimeout(null)
->run(function ($type, $output) {
$this->output->write($output);
Expand Down