Skip to content

Commit

Permalink
Merge pull request #11 from asgrim/download-implementation
Browse files Browse the repository at this point in the history
Initial implementation of bin/pie download
  • Loading branch information
asgrim authored Jul 9, 2024
2 parents 7b23795 + ff55375 commit c3e710e
Show file tree
Hide file tree
Showing 61 changed files with 5,735 additions and 667 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,26 @@ on:
jobs:
ci:
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x

windows-tests:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system:
- windows-latest
php-versions:
- '8.1'
- '8.2'
- '8.3'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: intl, sodium, zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: ramsey/composer-install@v3
- name: Run PHPUnit
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor/
/psalm.xml
/.phpunit.cache/
/.phpunit.result.cache
/.phpcs-cache
9 changes: 9 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace PHPSTORM_META {
override(\Psr\Container\ContainerInterface::get(0),
map([
'' => '@',
])
);
}
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
# 🥧 PIE (PHP Installer for Extensions)

(to be completed...)
You will need PHP 8.1 or newer to run PIE, but PIE can install an extension to any installed PHP version.

## Installing

## Usage

You can download an extension ready to be built or installed using the `download` command. For example, to download the
`example_pie_extension` extension, you would run:

```shell
$ bin/pie download asgrim/example-pie-extension
You are running PHP 8.3.7
Target PHP installation: 8.3.7 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.3)
Found package: asgrim/example-pie-extension:1.0.1 which provides ext-example_pie_extension
Extracted asgrim/example-pie-extension:1.0.1 source to: /tmp/pie_downloader_6645f07a28bec9.66045489/asgrim-example-pie-extension-769f906
$
```

If you are trying to install an extension for a different version of PHP, you may specify this on non-Windows systems
with the `--with-php-config` option like:

```shell
bin/pie download --with-php-config=/usr/bin/php-config7.2 my/extension
```

On all platforms, you may provide a path to the `php` executable itself using the `--with-php-path` option. This is an
example on Windows where PHP 8.1 is used to run PIE, but we want to download the extension for PHP 8.3:

```shell
> C:\php-8.1.7\php.exe bin/pie download --with-php-path=C:\php-8.3.6\php.exe asgrim/example-pie-extension
You are running PHP 8.1.7
Target PHP installation: 8.3.6 ts, vs16, on Windows x86_64 (from C:\php-8.3.6\php.exe)
Found package: asgrim/example-pie-extension:1.0.1 which provides ext-example_pie_extension
Extracted asgrim/example-pie-extension:1.0.1 source to: C:\path\to\temp\pie_downloader_66547faa7db3d7.06129230
```

And this is a very similar example (using PHP 8.1 to run PIE to download a PHP 8.3 extension) on a non-Windows platform:

```shell
$ php8.1 bin/pie download --with-php-path=/usr/bin/php8.3 asgrim/example-pie-extension
You are running PHP 8.1.28
Target PHP installation: 8.3.7 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.3)
Found package: asgrim/example-pie-extension:1.0.1 which provides ext-example_pie_extension
Extracted asgrim/example-pie-extension:1.0.1 source to: /tmp/pie_downloader_66547da1e6c685.25242810/asgrim-example-pie-extension-769f906
```

## Developing

### Testing
Expand Down
20 changes: 15 additions & 5 deletions bin/pie
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@

declare(strict_types=1);

use Php\Pie\Command;
namespace Php\Pie;

use Php\Pie\Command\DownloadCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/** @psalm-suppress UnresolvableInclude */
include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

$container = Container::factory();

$application = new Application('pie', 'dev-main');
$application->addCommands([
new Command\DownloadCommand(),
]);
$application->run();
$application->setCommandLoader(new ContainerCommandLoader(
$container,
[
'download' => DownloadCommand::class,
]
));
$application->run($container->get(InputInterface::class), $container->get(OutputInterface::class));
14 changes: 13 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"autoload-dev": {
"psr-4": {
"Php\\PieIntegrationTest\\": "test/integration/",
"Php\\PieUnitTest\\": "test/unit/"
}
},
Expand All @@ -26,11 +27,22 @@
],
"require": {
"php": "8.1.*||8.2.*||8.3.*",
"symfony/console": "^6.4"
"ext-zip": "*",
"azjezz/psl": "^2.9",
"composer/composer": "dev-main@dev",
"guzzlehttp/guzzle": "^7.8",
"guzzlehttp/psr7": "^2.6",
"illuminate/container": "^10.47",
"psr/http-message": "^2.0",
"symfony/console": "^6.4",
"symfony/process": "^6.4",
"webmozart/assert": "^1.11"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
"php-standard-library/psalm-plugin": "^2.3",
"phpunit/phpunit": "^10.5",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.22"
},
"config": {
Expand Down
Loading

0 comments on commit c3e710e

Please sign in to comment.