Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 73e2f81

Browse files
committed
Initial work on migration to Symfony
1 parent 5696501 commit 73e2f81

File tree

10 files changed

+405
-21
lines changed

10 files changed

+405
-21
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

‎bin/php-src-devtools‎

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
#!/usr/bin/env bash
2-
set -e
1+
#!/usr/bin/env php
2+
<?php
33

4-
function runInContainer()
5-
{
6-
docker run -i -t --rm -v`pwd`:/src/php-src aboks/php-src-devtools:latest "$@"
7-
}
4+
use Aboks\PhpSrcDevtools\Application;
5+
use Symfony\Component\Console\Input\ArgvInput;
86

9-
case "1ドル" in
10-
"build")
11-
runInContainer build
12-
;;
13-
"test")
14-
runInContainer test "${@:2}"
15-
;;
16-
"php")
17-
runInContainer run-cli "${@:2}"
18-
;;
19-
*)
20-
echo "Unknown command"
21-
exit 2
22-
;;
23-
esac
7+
require_once __DIR__ . '/../vendor/autoload.php';
8+
9+
$input = new ArgvInput();
10+
$input->setStream(STDIN);
11+
12+
$application = new Application();
13+
$application->run($input);

‎composer.json‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "aboks/php-src-devtools",
3+
"description": "Tools to make it easier to build, run and test PHP from source, using Docker",
4+
"require": {
5+
"php": "^7.1",
6+
"symfony/console": "^4.0",
7+
"symfony/process": "^4.0"
8+
},
9+
"license": "MIT",
10+
"authors": [
11+
{
12+
"name": "Arnout Boks",
13+
"email": "arnoutboks@gmail.com"
14+
}
15+
],
16+
"autoload": {
17+
"psr-4": {
18+
"Aboks\\PhpSrcDevtools\\": "src/"
19+
}
20+
}
21+
}

‎composer.lock‎

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/Application.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace Aboks\PhpSrcDevtools;
3+
4+
use Aboks\PhpSrcDevtools\Command\BuildCommand;
5+
use Aboks\PhpSrcDevtools\Command\PhpCommand;
6+
use Aboks\PhpSrcDevtools\Command\TestCommand;
7+
use Symfony\Component\Console\Application as ConsoleApplication;
8+
9+
class Application extends ConsoleApplication
10+
{
11+
public function __construct()
12+
{
13+
parent::__construct("php-src-devtools");
14+
15+
$this->add(new BuildCommand());
16+
$this->add(new TestCommand());
17+
$this->add(new PhpCommand());
18+
}
19+
}

‎src/Command/BuildCommand.php‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace Aboks\PhpSrcDevtools\Command;
3+
4+
use Aboks\PhpSrcDevtools\ConsoleProcessBridge;
5+
use Aboks\PhpSrcDevtools\DockerImage;
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
10+
class BuildCommand extends Command
11+
{
12+
13+
protected function configure()
14+
{
15+
$this->setName("build");
16+
$this->setDescription("Builds PHP from source");
17+
}
18+
19+
protected function execute(InputInterface $input, OutputInterface $output)
20+
{
21+
$dockerImage = new DockerImage();
22+
$process = $dockerImage->createProcess('build');
23+
$process->setTimeout(null);
24+
25+
return ConsoleProcessBridge::runProcessFromConsole($process, $input, $output);
26+
}
27+
}

‎src/Command/PhpCommand.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
namespace Aboks\PhpSrcDevtools\Command;
3+
4+
use Aboks\PhpSrcDevtools\ConsoleProcessBridge;
5+
use Aboks\PhpSrcDevtools\DockerImage;
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputArgument;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
11+
class PhpCommand extends Command
12+
{
13+
14+
protected function configure()
15+
{
16+
$this->setName("php");
17+
$this->setDescription("Runs the PHP CLI built from source");
18+
19+
$this->addArgument("args", InputArgument::IS_ARRAY | InputArgument::REQUIRED, "arguments to pass to the PHP CLI");
20+
}
21+
22+
protected function execute(InputInterface $input, OutputInterface $output)
23+
{
24+
$dockerImage = new DockerImage();
25+
$process = $dockerImage->createProcess('run-cli', $input->getArgument('args'));
26+
$process->setTimeout(null);
27+
28+
return ConsoleProcessBridge::runProcessFromConsole($process, $input, $output);
29+
}
30+
}

‎src/Command/TestCommand.php‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
namespace Aboks\PhpSrcDevtools\Command;
3+
4+
use Aboks\PhpSrcDevtools\ConsoleProcessBridge;
5+
use Aboks\PhpSrcDevtools\DockerImage;
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputArgument;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
11+
class TestCommand extends Command
12+
{
13+
14+
protected function configure()
15+
{
16+
$this->setName("test");
17+
$this->setDescription("Runs PHP's test suite");
18+
19+
$this->addArgument("tests", InputArgument::OPTIONAL, "subset of tests to run");
20+
}
21+
22+
protected function execute(InputInterface $input, OutputInterface $output)
23+
{
24+
$dockerArguments = [];
25+
if ($input->hasArgument('tests')) {
26+
$dockerArguments[] = $input->getArgument('tests');
27+
}
28+
29+
$dockerImage = new DockerImage();
30+
$process = $dockerImage->createProcess('test', $dockerArguments);
31+
$process->setTimeout(null);
32+
33+
return ConsoleProcessBridge::runProcessFromConsole($process, $input, $output);
34+
}
35+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /