• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aphiria / aphiria.com / 19786314830

29 Nov 2025 04:18PM UTC coverage: 65.472% (-1.6%) from 67.052%
19786314830

push

github

web-flow
Fixed Psalm and PHP-CS-Fixer issues (#88)

60 of 85 new or added lines in 12 files covered. (70.59%)

3 existing lines in 2 files now uncovered.

347 of 530 relevant lines covered (65.47%)

7.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Web/Console/Commands/ServeCommandHandler.php
1
<?php
2

3
/**
4
 * Aphiria
5
 *
6
 * @link      https://www.aphiria.com
7
 * @copyright Copyright (C) 2025 David Young
8
 * @license   https://github.com/aphiria/aphiria.com/blob/master/LICENSE.md
9
 */
10

11
declare(strict_types=1);
12

13
namespace App\Web\Console\Commands;
14

15
use Aphiria\Console\Commands\Attributes\Command;
16
use Aphiria\Console\Commands\ICommandHandler;
17
use Aphiria\Console\Input\Input;
18
use Aphiria\Console\Output\IOutput;
19
use Aphiria\Console\StatusCode;
20
use RuntimeException;
21

22
/**
23
 * Defines the handler for the serve command
24
 */
25
#[Command('app:serve', description: 'Runs the website and API locally')]
26
final class ServeCommandHandler implements ICommandHandler
27
{
28
    /**
29
     * @inheritdoc
30
     */
31
    public function handle(Input $input, IOutput $output)
32
    {
NEW
33
        $publicApiPath = \realpath(__DIR__ . '/../../../../public-api');
×
NEW
34
        $publicWebPath = \realpath(__DIR__ . '/../../../../public-web');
×
NEW
35
        $localhostRouterPath = \realpath(__DIR__ . '/../../../../localhost-router.php');
×
36

NEW
37
        if (!\is_string($publicApiPath)) {
×
NEW
38
            throw new RuntimeException('Public API path does not exist');
×
39
        }
40

NEW
41
        if (!\is_string($publicWebPath)) {
×
NEW
42
            throw new RuntimeException('Public web path does not exist');
×
43
        }
44

NEW
45
        if (!\is_string($localhostRouterPath)) {
×
NEW
46
            throw new RuntimeException('Localhost router path does not exist');
×
47
        }
48

49
        $runApiCommand = \sprintf(
×
50
            '%s -S %s -t "%s" "%s"',
×
51
            PHP_BINARY,
×
NEW
52
            \str_replace(['http://', 'https://'], ['', ''], (string) \getenv('APP_API_URL')),
×
NEW
53
            $publicApiPath,
×
NEW
54
            $localhostRouterPath,
×
55
        );
×
56
        $runWebCommand = \sprintf(
×
57
            '%s -S %s -t "%s"',
×
58
            PHP_BINARY,
×
NEW
59
            \str_replace(['http://', 'https://'], ['', ''], (string) \getenv('APP_WEB_URL')),
×
NEW
60
            $publicWebPath,
×
UNCOV
61
        );
×
62

63
        $this->runCommandsInBackground([$runApiCommand, $runWebCommand], $output);
×
64

65
        return StatusCode::Ok;
×
66
    }
67

68
    /**
69
     * Runs commands in the background, which allows blocking commands to be run in parallel
70
     *
71
     * @param list<string> $commands The commands to run
72
     * @param IOutput $output The output to write to
73
     */
74
    private function runCommandsInBackground(array $commands, IOutput $output): void
75
    {
76
        foreach ($commands as $command) {
×
77
            $output->writeln("<info>Running command:</info> $command");
×
78

79
            if (\strpos(\php_uname(), 'Windows') === 0) {
×
NEW
80
                $openProcess = \popen("start /B $command", 'r');
×
81

NEW
82
                if ($openProcess === false) {
×
NEW
83
                    throw new RuntimeException("Failed to run command: $command");
×
84
                }
85

NEW
86
                \pclose($openProcess);
×
87
            } else {
88
                \exec("$command> /dev/null &");
×
89
            }
90
        }
91
    }
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc