Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ jobs:

- name: Run tests
run: ./vendor/bin/pest

- name: Test cpx execution
if: matrix.os == 'ubuntu-latest' && matrix.php == '8.4'
run: |
composer global require cpx/cpx --no-interaction --prefer-dist
export PATH="$COMPOSER_HOME/vendor/bin:$PATH"
cpx knotsphp/publicip:dev-${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}} --help
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ It's recommended to install the library globally to use it in the command line.
composer global require knotsphp/publicip
```

Or run it without installing globally via [cpx](https://github.com/laravel/cpx):
```bash
cpx knotsphp/publicip
```

Then you can use the `publicip` command to get the public IP address of the current machine.
```bash
# In your project directory
Expand Down
15 changes: 11 additions & 4 deletions bin/publicip
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/env php
<?php

use KnotsPHP\PublicIP\Finders\PublicIP;
use KnotsPHP\PublicIP\Finders\PublicIPv4;
use KnotsPHP\PublicIP\Finders\PublicIPv6;
$autoloadPaths = array_filter([
$_composer_autoload_path ?? null,
__DIR__.'/../vendor/autoload.php',
__DIR__.'/../../../autoload.php',
]);

include $_composer_autoload_path ?? __DIR__.'/../vendor/autoload.php';
foreach ($autoloadPaths as $autoloadPath) {
if (is_file($autoloadPath)) {
require $autoloadPath;
break;
}
}

require __DIR__.'/../cli/publicip.php';
Loading