mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
commit
71571f685a
38
README.md
38
README.md
@ -35,6 +35,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
- [Verbose Setup](#verbose-setup)
|
- [Verbose Setup](#verbose-setup)
|
||||||
- [Cache Extensions](#cache-extensions)
|
- [Cache Extensions](#cache-extensions)
|
||||||
- [Cache Composer Dependencies](#cache-composer-dependencies)
|
- [Cache Composer Dependencies](#cache-composer-dependencies)
|
||||||
|
- [Cache Node.js Dependencies](#cache-nodejs-dependencies)
|
||||||
- [Problem Matchers](#problem-matchers)
|
- [Problem Matchers](#problem-matchers)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [License](#scroll-license)
|
- [License](#scroll-license)
|
||||||
@ -338,7 +339,7 @@ jobs:
|
|||||||
|
|
||||||
### Cache Extensions
|
### Cache Extensions
|
||||||
|
|
||||||
You can persist PHP extensions you setup using the [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") and [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Actions. Extensions which take very long to setup if cached are available in the next workflow run and enabled directly which reduces the workflow execution time.
|
You can cache PHP extensions using [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") and [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Actions. Extensions which take very long to setup if cached are available in the next workflow run and enabled directly which reduces the workflow execution time.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
@ -378,12 +379,12 @@ steps:
|
|||||||
|
|
||||||
### Cache Composer Dependencies
|
### Cache Composer Dependencies
|
||||||
|
|
||||||
You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
|
If your project uses composer, you can persist composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
|
||||||
|
|
||||||
**Note:** Please do not cache `vendor` directory using `action/cache` as that will have side-effects.
|
**Note:** Please do not cache `vendor` directory using `action/cache` as that will have side-effects.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Get Composer Cache Directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
@ -394,7 +395,7 @@ You can persist composer's internal cache directory using the [`action/cache`](h
|
|||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install dependencies
|
||||||
run: composer install --prefer-dist
|
run: composer install --prefer-dist
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -404,6 +405,25 @@ In the above example, if you support a range of `composer` dependencies and do n
|
|||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Cache Node.js Dependencies
|
||||||
|
|
||||||
|
If you project has node.js dependencies, you can persist npm's or yarn's internal cache directory. Dependencies cached install faster. The files cached are available across check-runs and will reduce the workflow execution time.
|
||||||
|
|
||||||
|
**Note:** Please do not cache `node_modules` directory as that will have side-effects.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Get node.js cache directory
|
||||||
|
id: node-cache-dir
|
||||||
|
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ${{ steps.node-cache-dir.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
|
||||||
|
restore-keys: ${{ runner.os }}-node-
|
||||||
|
```
|
||||||
|
|
||||||
### Problem Matchers
|
### Problem Matchers
|
||||||
|
|
||||||
#### PHP
|
#### PHP
|
||||||
@ -411,7 +431,7 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
|||||||
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Problem Matchers for PHP
|
- name: Setup problem matchers for PHP
|
||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -420,7 +440,7 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu
|
|||||||
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Problem Matchers for PHPUnit
|
- name: Setup problem matchers for PHPUnit
|
||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -472,7 +492,7 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package
|
|||||||
|
|
||||||
## :scroll: License
|
## :scroll: License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). This project has multiple [dependencies](#dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
|
The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). This project has multiple [dependencies](#bookmark-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
|
||||||
|
|
||||||
## :+1: Contributions
|
## :+1: Contributions
|
||||||
|
|
||||||
@ -483,8 +503,8 @@ Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "sh
|
|||||||
If this action helped you.
|
If this action helped you.
|
||||||
|
|
||||||
- Please star the project and share it with the community.
|
- Please star the project and share it with the community.
|
||||||
- If you blog, write about your experience while using this action.
|
- If you blog, write about your experience of using this action.
|
||||||
- I maintain this in my free time, please support me with a [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") subscription or a one time contribution using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal").
|
- Please support me with a [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") subscription or a contribution using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") so that I'm able to actively maintain this project.
|
||||||
- If you need any help using this, please contact me using [Codementor](https://www.codementor.io/shivammathur "Shivam Mathur Codementor")
|
- If you need any help using this, please contact me using [Codementor](https://www.codementor.io/shivammathur "Shivam Mathur Codementor")
|
||||||
|
|
||||||
## :bookmark: Dependencies
|
## :bookmark: Dependencies
|
||||||
|
73
package-lock.json
generated
73
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -575,18 +575,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@sinonjs/commons": {
|
"@sinonjs/commons": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.1.tgz",
|
||||||
"integrity": "sha512-qbk9AP+cZUsKdW1GJsBpxPKFmCJ0T8swwzVje3qFd+AkQb74Q/tiuzrdfFg8AD2g5HH/XbE/I8Uc1KYHVYWfhg==",
|
"integrity": "sha512-Debi3Baff1Qu1Unc3mjJ96MgpbwTn43S1+9yJ0llWygPwDNu2aaWBD6yc9y/Z8XDRNhx7U+u2UDg2OGQXkclUQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"type-detect": "4.0.8"
|
"type-detect": "4.0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/babel__core": {
|
"@types/babel__core": {
|
||||||
"version": "7.1.4",
|
"version": "7.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.5.tgz",
|
||||||
"integrity": "sha512-c/5MuRz5HM4aizqL5ViYfW4iEnmfPcfbH4Xa6GgLT21dMc1NGeNnuS6egHheOmP+kCJ9CAzC4pv4SDCWTnRkbg==",
|
"integrity": "sha512-+ckxwNj892FWgvwrUWLOghQ2JDgOgeqTPwrcl+0t1pG59CP8qMJ6S/efmEd999vCFSJKOpyMakvU+w380rduUQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/parser": "^7.1.0",
|
"@babel/parser": "^7.1.0",
|
||||||
@ -616,9 +616,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/babel__traverse": {
|
"@types/babel__traverse": {
|
||||||
"version": "7.0.8",
|
"version": "7.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.9.tgz",
|
||||||
"integrity": "sha512-yGeB2dHEdvxjP0y4UbRtQaSkXJ9649fYCmIdRoul5kfAoGCwxuCbMhag0k3RPfnuh9kPGm8x89btcfDEXdVWGw==",
|
"integrity": "sha512-jEFQ8L1tuvPjOI8lnpaf73oCJe+aoxL6ygqSy6c8LcW98zaC+4mzWuQIRCEvKeCOu+lbqdXcg4Uqmm1S8AP1tw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/types": "^7.3.0"
|
"@babel/types": "^7.3.0"
|
||||||
@ -662,9 +662,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/jest": {
|
"@types/jest": {
|
||||||
"version": "25.1.2",
|
"version": "25.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.3.tgz",
|
||||||
"integrity": "sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ==",
|
"integrity": "sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"jest-diff": "^25.1.0",
|
"jest-diff": "^25.1.0",
|
||||||
@ -678,9 +678,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "13.7.2",
|
"version": "13.7.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.4.tgz",
|
||||||
"integrity": "sha512-uvilvAQbdJvnSBFcKJ2td4016urcGvsiR+N4dHGU87ml8O2Vl6l+ErOi9w0kXSPiwJ1AYlIW+0pDXDWWMOiWbw==",
|
"integrity": "sha512-oVeL12C6gQS/GAExndigSaLxTrKpQPxewx9bOcwfvJiJge4rr7wNaph4J+ns5hrmIV2as5qxqN8YKthn9qh0jw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/parse-json": {
|
"@types/parse-json": {
|
||||||
@ -3827,9 +3827,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"make-error": {
|
"make-error": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||||
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
|
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"makeerror": {
|
"makeerror": {
|
||||||
@ -5517,9 +5517,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
"version": "25.2.0",
|
"version": "25.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.1.tgz",
|
||||||
"integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==",
|
"integrity": "sha512-TnntkEEjuXq/Gxpw7xToarmHbAafgCaAzOpnajnFC6jI7oo1trMzAHA04eWpc3MhV6+yvhE8uUBAmN+teRJh0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bs-logger": "0.x",
|
"bs-logger": "0.x",
|
||||||
@ -5531,36 +5531,21 @@
|
|||||||
"mkdirp": "0.x",
|
"mkdirp": "0.x",
|
||||||
"resolve": "1.x",
|
"resolve": "1.x",
|
||||||
"semver": "^5.5",
|
"semver": "^5.5",
|
||||||
"yargs-parser": "10.x"
|
"yargs-parser": "^16.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"camelcase": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
|
|
||||||
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.7.1",
|
"version": "5.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
|
||||||
"yargs-parser": {
|
|
||||||
"version": "10.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz",
|
|
||||||
"integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"camelcase": "^4.1.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslib": {
|
"tslib": {
|
||||||
"version": "1.10.0",
|
"version": "1.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.0.tgz",
|
||||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
|
"integrity": "sha512-BmndXUtiTn/VDDrJzQE7Mm22Ix3PxgLltW9bSNLoeCY31gnG2OPx0QqJnuc9oMIKioYrz487i6K9o4Pdn0j+Kg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
@ -5618,9 +5603,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "3.7.5",
|
"version": "3.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz",
|
||||||
"integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
|
"integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"union-value": {
|
"union-value": {
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -30,8 +30,8 @@
|
|||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.2",
|
"@types/jest": "^25.1.3",
|
||||||
"@types/node": "^13.7.2",
|
"@types/node": "^13.7.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
||||||
"@typescript-eslint/parser": "^2.20.0",
|
"@typescript-eslint/parser": "^2.20.0",
|
||||||
"@zeit/ncc": "^0.21.1",
|
"@zeit/ncc": "^0.21.1",
|
||||||
@ -44,8 +44,8 @@
|
|||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^25.1.0",
|
"jest-circus": "^25.1.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^25.2.0",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.8.2"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"skipCI": true,
|
"skipCI": true,
|
||||||
|
@ -180,6 +180,15 @@ port_setup_php() {
|
|||||||
add_pecl_old "$1"
|
add_pecl_old "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_php() {
|
||||||
|
action=$1
|
||||||
|
step_log "Setup PHP"
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
|
||||||
|
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||||
|
brew "$action" shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
@ -190,7 +199,6 @@ existing_version=$(php-config --version | cut -c 1-3)
|
|||||||
[[ -z "${update}" ]] && update='false' || update="${update}"
|
[[ -z "${update}" ]] && update='false' || update="${update}"
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
step_log "Setup PHP"
|
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
|
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
|
||||||
export TERM=xterm
|
export TERM=xterm
|
||||||
@ -202,17 +210,14 @@ if [[ "$version" =~ $old_versions ]]; then
|
|||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
port_setup_php $nodot_version >/dev/null 2>&1
|
port_setup_php $nodot_version >/dev/null 2>&1
|
||||||
status="Installed"
|
status="Installed"
|
||||||
elif [ "$existing_version" != "$version" ] || [ "$update" = "true" ]; then
|
elif [ "$existing_version" != "$version" ]; then
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
|
setup_php "install"
|
||||||
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
status="Installed"
|
||||||
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then
|
||||||
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
setup_php "upgrade"
|
||||||
if [ "$update" = "true" ]; then
|
|
||||||
status="Updated to"
|
status="Updated to"
|
||||||
else
|
else
|
||||||
status="Installed"
|
step_log "Setup PHP"
|
||||||
fi
|
|
||||||
else
|
|
||||||
status="Found"
|
status="Found"
|
||||||
fi
|
fi
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
@ -25,6 +25,7 @@ update_ppa() {
|
|||||||
ppa="ondrej-ubuntu-php*.list"
|
ppa="ondrej-ubuntu-php*.list"
|
||||||
fi
|
fi
|
||||||
find /etc/apt/sources.list.d -type f -name "$ppa" -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
find /etc/apt/sources.list.d -type f -name "$ppa" -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||||
|
ppa_updated="true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ add_extension() {
|
|||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if [[ "$version" =~ $old_versions ]]; then
|
if [[ "$version" =~ $old_versions ]]; then
|
||||||
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version} && ppa_updated='true'"
|
install_command="update_ppa && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
|
||||||
fi
|
fi
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
@ -69,7 +70,7 @@ add_extension() {
|
|||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
elif ! php -m | grep -i -q -w "$extension"; then
|
||||||
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
(eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
(update_ppa && eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled" && ppa_updated="true") ||
|
(update_ppa && eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
(sudo pecl install -f "$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
(sudo pecl install -f "$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
fi
|
fi
|
||||||
@ -140,7 +141,6 @@ update_extension() {
|
|||||||
version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version")
|
version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version")
|
||||||
if [ -z "$version_exists" ]; then
|
if [ -z "$version_exists" ]; then
|
||||||
update_ppa
|
update_ppa
|
||||||
ppa_updated="true"
|
|
||||||
fi
|
fi
|
||||||
$apt_install php"$version"-"$extension"
|
$apt_install php"$version"-"$extension"
|
||||||
fi
|
fi
|
||||||
@ -242,6 +242,28 @@ switch_version() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to get PHP version in semver format
|
||||||
|
php_semver() {
|
||||||
|
if [ ! "$version" = "8.0" ]; then
|
||||||
|
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
|
||||||
|
else
|
||||||
|
php -v | head -n 1 | cut -f 2 -d ' '
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update PHP
|
||||||
|
update_php() {
|
||||||
|
update_ppa
|
||||||
|
initial_version=$(php_semver)
|
||||||
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||||
|
updated_version=$(php_semver)
|
||||||
|
if [ "$updated_version" != "$initial_version" ]; then
|
||||||
|
status="Updated to"
|
||||||
|
else
|
||||||
|
status="Switched to"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
@ -268,15 +290,13 @@ if [ "$existing_version" != "$version" ]; then
|
|||||||
version_exists=$(apt-cache policy -- php"$version" | grep "$version")
|
version_exists=$(apt-cache policy -- php"$version" | grep "$version")
|
||||||
if [ -z "$version_exists" ]; then
|
if [ -z "$version_exists" ]; then
|
||||||
update_ppa
|
update_ppa
|
||||||
ppa_updated="true"
|
|
||||||
fi
|
fi
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
status="Installed"
|
status="Installed"
|
||||||
else
|
else
|
||||||
if [ "$update" = "true" ]; then
|
if [ "$update" = "true" ]; then
|
||||||
$apt_install php"$version" >/dev/null 2>&1
|
update_php
|
||||||
status="Updated to"
|
|
||||||
else
|
else
|
||||||
status="Switched to"
|
status="Switched to"
|
||||||
fi
|
fi
|
||||||
@ -289,18 +309,13 @@ if [ "$existing_version" != "$version" ]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
if [ "$update" = "true" ]; then
|
if [ "$update" = "true" ]; then
|
||||||
$apt_install php"$version" >/dev/null 2>&1
|
update_php
|
||||||
status="Updated to"
|
|
||||||
else
|
else
|
||||||
status="Found"
|
status="Found"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
semver=$(php_semver)
|
||||||
if [ ! "$version" = "8.0" ]; then
|
|
||||||
semver=$(echo "$semver" | cut -f 1 -d '-')
|
|
||||||
fi
|
|
||||||
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
Loading…
Reference in New Issue
Block a user