Skip to content

Commit 710c876

Browse files
authored
Merge pull request #1667 from hydephp/update-debug-command
Update debug command to print binary path when running in the Phar standalone
2 parents e9a4cc2 + c18f45a commit 710c876

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This serves two purposes:
1919
### Changed
2020
- The `features` array in the `config/hyde.php` configuration file is now an array of `Feature` enums in https://github.com/hydephp/develop/pull/1650
2121
- Sitemap generation will now be skipped if a base URL is not set, as Google now will not index sitemaps without a base URL in https://github.com/hydephp/develop/pull/1660
22+
- Updated the debug command to print the binary path when running in a standalone Phar in https://github.com/hydephp/develop/pull/1667
2223

2324
### Deprecated
2425
- Deprecated the static `Features` flag methods used in the configuration files in https://github.com/hydephp/develop/pull/1650 and will be removed in HydePHP v2.0

packages/framework/src/Console/Commands/DebugCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use Hyde\Hyde;
88
use Hyde\Facades\Config;
99
use Composer\InstalledVersions;
10+
use Hyde\Foundation\PharSupport;
1011
use LaravelZero\Framework\Commands\Command;
1112

1213
use function str_replace;
1314
use function realpath;
1415
use function app;
16+
use function get_included_files;
1517

1618
/**
1719
* Print debug information.
@@ -50,6 +52,10 @@ public function handle(): int
5052
$this->printVerbosePathInformation();
5153
} else {
5254
$this->comment('Project directory: '.Hyde::path());
55+
56+
if (PharSupport::running()) {
57+
$this->comment('Application binary path: '.get_included_files()[0]);
58+
}
5359
}
5460
$this->newLine();
5561

packages/framework/tests/Feature/Commands/DebugCommandTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
namespace Hyde\Framework\Testing\Feature\Commands;
66

7+
use Mockery;
78
use Hyde\Testing\TestCase;
9+
use Hyde\Foundation\PharSupport;
10+
use Illuminate\Console\OutputStyle;
11+
use Hyde\Console\Commands\DebugCommand;
812

913
/**
1014
* @covers \Hyde\Console\Commands\DebugCommand
@@ -46,4 +50,33 @@ public function testItPrintsVerboseDebugInformation()
4650
->expectsOutputToContain('(real)')
4751
->assertExitCode(0);
4852
}
53+
54+
public function testItPrintsPharDebugInformation()
55+
{
56+
PharSupport::mock('running', true);
57+
58+
$wasCalled = false;
59+
60+
$output = Mockery::mock(OutputStyle::class, [
61+
'writeln' => null,
62+
'newLine' => null,
63+
'isVerbose' => false,
64+
])->makePartial();
65+
66+
$output->shouldReceive('writeln')->withArgs(function ($message) use (&$wasCalled) {
67+
if (str_contains($message, 'Application binary path:')) {
68+
$wasCalled = true;
69+
}
70+
71+
return true;
72+
});
73+
74+
$command = new DebugCommand();
75+
$command->setOutput($output);
76+
$command->handle();
77+
78+
$this->assertTrue($wasCalled, 'Expected "Application binary path" to be called');
79+
80+
PharSupport::clearMocks();
81+
}
4982
}

0 commit comments

Comments
 (0)