Skip to content

Commit 6b43085

Browse files
committed
feat: Import LaravelZero.
1 parent 94cedf8 commit 6b43085

24 files changed

+6700
-181
lines changed

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
.idea
2+
.php_cs
3+
.php_cs.cache
24
.phpunit.result.cache
35
build
4-
composer.lock
56
coverage
6-
docs
77
phpunit.xml
8-
phpstan.neon
9-
testbench.yaml
8+
psalm.xml
109
vendor
11-
node_modules
File renamed without changes.

app/Commands/Command.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Commands;
4+
5+
use App\Support\ConfigRepository;
6+
use LaravelZero\Framework\Commands\Command as BaseCommand;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
abstract class Command extends BaseCommand
10+
{
11+
public function __construct(
12+
public ConfigRepository $config,
13+
) {
14+
parent::__construct();
15+
}
16+
17+
protected function runCommand($command, array $arguments, OutputInterface $output)
18+
{
19+
return $this->resolveCommand($command)->run(
20+
$this->createInputFromArguments($arguments), $output
21+
);
22+
}
23+
}

app/Providers/AppServiceProvider.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class AppServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Bootstrap any application services.
11+
*
12+
* @return void
13+
*/
14+
public function boot()
15+
{
16+
//
17+
}
18+
19+
/**
20+
* Register any application services.
21+
*
22+
* @return void
23+
*/
24+
public function register()
25+
{
26+
//
27+
}
28+
}

app/Support/ConfigRepository.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace App\Support;
4+
5+
use Spatie\Valuestore\Valuestore;
6+
7+
/**
8+
* @property-read ?string $accessToken
9+
* @property-read ?string $gitHubUsername
10+
*/
11+
class ConfigRepository
12+
{
13+
protected Valuestore $valuestore;
14+
15+
public function __construct()
16+
{
17+
$path = "{$this->findHomeDirectory()}/.laravel-remote.json";
18+
19+
$this->valuestore = Valuestore::make($path);
20+
}
21+
22+
public function setHost(string $name, array $host = []): self
23+
{
24+
$this->valuestore->put([
25+
"hosts" => [
26+
$name => $host,
27+
]
28+
]);
29+
30+
return $this;
31+
}
32+
33+
public function __get(string $name): mixed
34+
{
35+
return $this->valuestore->get($name);
36+
}
37+
38+
public function flush(): self
39+
{
40+
$this->valuestore->flush();
41+
42+
return $this;
43+
}
44+
45+
protected function findHomeDirectory(): ?string
46+
{
47+
if (str_starts_with(PHP_OS, 'WIN')) {
48+
if (empty($_SERVER['HOMEDRIVE']) || empty($_SERVER['HOMEPATH'])) {
49+
return null;
50+
}
51+
52+
$homeDirectory = $_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH'];
53+
54+
return rtrim($homeDirectory, DIRECTORY_SEPARATOR);
55+
}
56+
57+
if ($homeDirectory = getenv('HOME')) {
58+
return rtrim($homeDirectory, DIRECTORY_SEPARATOR);
59+
}
60+
61+
return null;
62+
}
63+
}

bootstrap/app.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| Create The Application
6+
|--------------------------------------------------------------------------
7+
|
8+
| The first thing we will do is create a new Laravel application instance
9+
| which serves as the "glue" for all the components of Laravel, and is
10+
| the IoC container for the system binding all of the various parts.
11+
|
12+
*/
13+
14+
$app = new LaravelZero\Framework\Application(
15+
dirname(__DIR__)
16+
);
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Bind Important Interfaces
21+
|--------------------------------------------------------------------------
22+
|
23+
| Next, we need to bind some important interfaces into the container so
24+
| we will be able to resolve them when needed. The kernels serve the
25+
| incoming requests to this application from both the web and CLI.
26+
|
27+
*/
28+
29+
$app->singleton(
30+
Illuminate\Contracts\Console\Kernel::class,
31+
LaravelZero\Framework\Kernel::class
32+
);
33+
34+
$app->singleton(
35+
Illuminate\Contracts\Debug\ExceptionHandler::class,
36+
Illuminate\Foundation\Exceptions\Handler::class
37+
);
38+
39+
/*
40+
|--------------------------------------------------------------------------
41+
| Return The Application
42+
|--------------------------------------------------------------------------
43+
|
44+
| This script returns the application instance. The instance is given to
45+
| the calling script so we can separate the building of the instances
46+
| from the actual running of the application and sending responses.
47+
|
48+
*/
49+
50+
return $app;

box.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"chmod": "0755",
3+
"directories": [
4+
"app",
5+
"bootstrap",
6+
"config",
7+
"vendor"
8+
],
9+
"files": [
10+
"composer.json"
11+
],
12+
"exclude-composer-files": false,
13+
"compression": "GZ",
14+
"compactors": [
15+
"KevinGH\\Box\\Compactor\\Php",
16+
"KevinGH\\Box\\Compactor\\Json"
17+
]
18+
}

composer.json

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
],
2222
"require": {
2323
"php": "^8.1",
24-
"spatie/laravel-package-tools": "^1.13.0",
25-
"illuminate/contracts": "^9.0"
24+
"laravel-zero/framework": "^9.2",
25+
"nunomaduro/termwind": "^1.14",
26+
"spatie/laravel-remote": "^1.3",
27+
"spatie/valuestore": "^1.3"
2628
},
2729
"require-dev": {
2830
"laravel/pint": "^1.0",
2931
"nunomaduro/collision": "^6.0",
3032
"nunomaduro/larastan": "^2.0.1",
31-
"orchestra/testbench": "^7.0",
3233
"pestphp/pest": "^1.21",
33-
"pestphp/pest-plugin-laravel": "^1.1",
3434
"phpstan/extension-installer": "^1.1",
3535
"phpstan/phpstan-deprecation-rules": "^1.0",
3636
"phpstan/phpstan-phpunit": "^1.0",
@@ -39,39 +39,30 @@
3939
},
4040
"autoload": {
4141
"psr-4": {
42-
"Spatie\\GlobalLaravelRemote\\": "src",
43-
"Spatie\\GlobalLaravelRemote\\Database\\Factories\\": "database/factories"
42+
"App\\": "app/"
4443
}
4544
},
4645
"autoload-dev": {
4746
"psr-4": {
48-
"Spatie\\GlobalLaravelRemote\\Tests\\": "tests"
47+
"Tests\\": "tests/"
4948
}
5049
},
5150
"scripts": {
52-
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
5351
"analyse": "vendor/bin/phpstan analyse",
52+
"build": "php global-laravel-remote app:build global-laravel-remote",
5453
"test": "vendor/bin/pest",
5554
"test-coverage": "vendor/bin/pest --coverage",
5655
"format": "vendor/bin/pint"
5756
},
5857
"config": {
58+
"preferred-install": "dist",
5959
"sort-packages": true,
60+
"optimize-autoloader": true,
6061
"allow-plugins": {
61-
"pestphp/pest-plugin": true,
62-
"phpstan/extension-installer": true
63-
}
64-
},
65-
"extra": {
66-
"laravel": {
67-
"providers": [
68-
"Spatie\\GlobalLaravelRemote\\GlobalLaravelRemoteServiceProvider"
69-
],
70-
"aliases": {
71-
"GlobalLaravelRemote": "Spatie\\GlobalLaravelRemote\\Facades\\GlobalLaravelRemote"
72-
}
62+
"pestphp/pest-plugin": true
7363
}
7464
},
7565
"minimum-stability": "dev",
76-
"prefer-stable": true
66+
"prefer-stable": true,
67+
"bin": ["global-laravel-remote"]
7768
}

0 commit comments

Comments
 (0)