Skip to content

Commit

Permalink
Merge pull request #20 from phar-io/docs
Browse files Browse the repository at this point in the history
Clean up readme
  • Loading branch information
sebastianfeldmann authored Mar 27, 2021
2 parents e73ad16 + fff3b35 commit 925104e
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
# Deploying PHAR files via Composer

If you have a tool that behaves like a binary and want to distribute this tool as a
PHAR file instead of the source-code, but you don't want to give up the convenience
PHAR file instead of the source-code but don't want to give up the convenience
to install your tool via Composer you can use this library to create a Composer-Plugin
that deals with this in no time.

## Motivation

Tools like `PHPUnit`, `PHPStan`, `Psalm` and many others should be installed as PHAR to avoid
Tools like `PHPUnit`, `PHPStan`, `Psalm` and many others are best installed as PHAR to avoid
version conflicts between your dev tools and your own source code. But since so many developers
just want to use `Composer` to install stuff this project was created to simplify the deployment
of a PHAR file via `Composer`.
just want to use `Composer` to install all the tools this project was created to simplify the
deployment of PHAR files via `Composer`.

## Create your own

To create a Composer-Plugin that installs your PHAR files follow these 3 steps.

### Step 1 - Create your Composer-Plugin repository
### Step 1 - Create your Composer-Plugin

The easiest way is to run the following command and follow the instructions.

```bash
composer create-project phar-io/mediator /path/to/your/directory/
```

The only thing you have to edit is the `distributor.xml` configuration file.
Just change the `packageName` and `<phar>` configuration and you are good to go.
This will create the plugin in the specified directory.
Make sure the information in your `distibutor.xml` configuration is correct.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<distributor xmlns="https://phar.io/composer-distributor"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://phar.io/xml/distributor/1.0/schema.xsd"
packageName="yournamespace/pluginname"
keyDirectory="keys">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://phar.io/xml/distributor/1.0/schema.xsd"
packageName="yournamespace/pluginname"
keyDirectory="keys">

<phar name="pharname"
file="https://github.com/yournamespace/pluginname/releases/download/{{version}}/pharname.phar"
signature="https://github.com/yournamespace/pluginname/releases/download/{{version}}/pharname.phar.asc"/>
<phar name="pharname"
file="https://github.com/yournamespace/pluginname/releases/download/{{version}}/pharname.phar"
signature="https://github.com/yournamespace/pluginname/releases/download/{{version}}/pharname.phar.asc"/>

</distributor>
```

### Step 2 - Create a Composer package for your plugin on packagist

Create a git repository for your plugin on the platform of your choosing. Then head over to
packagist.org and set up a Composer package for your plugin.
[packagist.org](https://packagist.org) and set up a Composer package for your plugin.

⚠️ REMINDER ⚠️

Make sure you add the same tags to your plugin repository as on your source code repository.
Remember to tag your plugin repository as well whenever you release a new version.

### Step 3 - Change your installation instructions
### Step 3 - Enjoy your PHAR deployment

Now everybody can install your PHAR by running the following command.

Expand Down

0 comments on commit 925104e

Please sign in to comment.