mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-11-04 17:06:37 +07:00 
			
		
		
		
	
							
								
								
									
										26
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								README.md
									
									
									
									
									
								
							@ -10,7 +10,7 @@
 | 
			
		||||
  <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
 | 
			
		||||
  <a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
 | 
			
		||||
  <a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
 | 
			
		||||
  <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>  
 | 
			
		||||
  <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
Setup PHP with required extensions, php.ini configuration, code-coverage support and tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
 | 
			
		||||
@ -62,7 +62,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
 | 
			
		||||
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`|
 | 
			
		||||
 | 
			
		||||
## :heavy_plus_sign: PHP Extension Support
 | 
			
		||||
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input. 
 | 
			
		||||
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
 | 
			
		||||
- On `windows` extensions which have `windows` binary on `PECL` can be installed.
 | 
			
		||||
- On `macOS` extensions which are on `PECL` can be installed.
 | 
			
		||||
- Extensions which are installed along with PHP if specified are enabled.
 | 
			
		||||
@ -70,11 +70,11 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
 | 
			
		||||
 | 
			
		||||
## :wrench: Tools Support
 | 
			
		||||
 | 
			
		||||
The latest version of the following tools can be setup globally using the `tools` input
 | 
			
		||||
The latest version of the following tools can be setup globally using the `tools` input.
 | 
			
		||||
 | 
			
		||||
`composer`, `codeception`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
 | 
			
		||||
 | 
			
		||||
```yml
 | 
			
		||||
```yaml
 | 
			
		||||
uses: shivammathur/setup-php@v1
 | 
			
		||||
with:
 | 
			
		||||
  php-version: '7.4'
 | 
			
		||||
@ -93,7 +93,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
 | 
			
		||||
```yaml
 | 
			
		||||
uses: shivammathur/setup-php@v1
 | 
			
		||||
with:
 | 
			
		||||
  php-version: '7.4'  
 | 
			
		||||
  php-version: '7.4'
 | 
			
		||||
  coverage: xdebug
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,7 @@ with:
 | 
			
		||||
 | 
			
		||||
### Disable coverage
 | 
			
		||||
 | 
			
		||||
Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
 | 
			
		||||
Specify `coverage: none` to disable both `Xdebug` and `PCOV`.  
 | 
			
		||||
Consider disabling the coverage using this PHP action for these reasons.
 | 
			
		||||
 | 
			
		||||
- You are not generating coverage reports while testing.
 | 
			
		||||
@ -141,7 +141,7 @@ Inputs supported by this GitHub Action.
 | 
			
		||||
 | 
			
		||||
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
 | 
			
		||||
 | 
			
		||||
### Basic Setup 
 | 
			
		||||
### Basic Setup
 | 
			
		||||
 | 
			
		||||
> Setup a particular PHP version.
 | 
			
		||||
 | 
			
		||||
@ -166,9 +166,9 @@ steps:
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
jobs:
 | 
			
		||||
  run:    
 | 
			
		||||
  run:
 | 
			
		||||
    runs-on: ${{ matrix.operating-system }}
 | 
			
		||||
    strategy:      
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        operating-system: [ubuntu-latest, windows-latest, macOS-latest]
 | 
			
		||||
        php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
 | 
			
		||||
@ -187,7 +187,7 @@ jobs:
 | 
			
		||||
        tools: php-cs-fixer, phpunit #optional, setup tools globally
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Experimental Setup 
 | 
			
		||||
### Experimental Setup
 | 
			
		||||
 | 
			
		||||
> Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP.
 | 
			
		||||
 | 
			
		||||
@ -223,10 +223,10 @@ You can persist composer's internal cache directory using the [`action/cache`](h
 | 
			
		||||
  id: composer-cache
 | 
			
		||||
  run: echo "::set-output name=dir::$(composer config cache-files-dir)"
 | 
			
		||||
 | 
			
		||||
- name: Cache dependencies  
 | 
			
		||||
- name: Cache dependencies
 | 
			
		||||
  uses: actions/cache@v1
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.composer-cache.outputs.dir }}   
 | 
			
		||||
    path: ${{ steps.composer-cache.outputs.dir }}
 | 
			
		||||
    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
 | 
			
		||||
    restore-keys: ${{ runner.os }}-composer-
 | 
			
		||||
 | 
			
		||||
@ -236,7 +236,7 @@ You can persist composer's internal cache directory using the [`action/cache`](h
 | 
			
		||||
 | 
			
		||||
In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
 | 
			
		||||
 | 
			
		||||
```yml
 | 
			
		||||
```yaml
 | 
			
		||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} 
 | 
			
		||||
``` 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,9 @@ jest.mock('../src/install', () => ({
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      let script = 'initial script ' + filename + version + os_version;
 | 
			
		||||
      if (tools_csv) {
 | 
			
		||||
        script += 'add_tool';
 | 
			
		||||
      }
 | 
			
		||||
      if (extension_csv) {
 | 
			
		||||
        script += 'install extensions';
 | 
			
		||||
      }
 | 
			
		||||
@ -29,9 +32,6 @@ jest.mock('../src/install', () => ({
 | 
			
		||||
      if (coverage_driver) {
 | 
			
		||||
        script += 'set coverage driver';
 | 
			
		||||
      }
 | 
			
		||||
      if (tools_csv) {
 | 
			
		||||
        script += 'add_tool';
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return script;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@ -2042,6 +2042,7 @@ function build(filename, version, os_version) {
 | 
			
		||||
            tools_csv = 'pecl, ' + tools_csv;
 | 
			
		||||
        }
 | 
			
		||||
        let script = yield utils.readScript(filename, version, os_version);
 | 
			
		||||
        script += yield tools.addTools(tools_csv, os_version);
 | 
			
		||||
        if (extension_csv) {
 | 
			
		||||
            script += yield extensions.addExtension(extension_csv, version, os_version);
 | 
			
		||||
        }
 | 
			
		||||
@ -2051,7 +2052,6 @@ function build(filename, version, os_version) {
 | 
			
		||||
        if (coverage_driver) {
 | 
			
		||||
            script += yield coverage.addCoverage(coverage_driver, version, os_version);
 | 
			
		||||
        }
 | 
			
		||||
        script += yield tools.addTools(tools_csv, os_version);
 | 
			
		||||
        return yield utils.writeScript(filename, script);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,8 @@ export async function build(
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let script: string = await utils.readScript(filename, version, os_version);
 | 
			
		||||
  script += await tools.addTools(tools_csv, os_version);
 | 
			
		||||
 | 
			
		||||
  if (extension_csv) {
 | 
			
		||||
    script += await extensions.addExtension(extension_csv, version, os_version);
 | 
			
		||||
  }
 | 
			
		||||
@ -43,7 +45,6 @@ export async function build(
 | 
			
		||||
  if (coverage_driver) {
 | 
			
		||||
    script += await coverage.addCoverage(coverage_driver, version, os_version);
 | 
			
		||||
  }
 | 
			
		||||
  script += await tools.addTools(tools_csv, os_version);
 | 
			
		||||
 | 
			
		||||
  return await utils.writeScript(filename, script);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,15 @@
 | 
			
		||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
 | 
			
		||||
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
 | 
			
		||||
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
 | 
			
		||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
 | 
			
		||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
 | 
			
		||||
for tool in php-config phpize; do
 | 
			
		||||
  if [ -e "/usr/bin/$tool$2" ]; then
 | 
			
		||||
    sudo update-alternatives --set $tool /usr/bin/"$tool$2"
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
 | 
			
		||||
  sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
 | 
			
		||||
  for tool in php-config phpize; do
 | 
			
		||||
    if [ -e "/usr/bin/$tool$2" ]; then
 | 
			
		||||
      sudo update-alternatives --set $tool /usr/bin/"$tool$2"
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
  cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
 | 
			
		||||
  cd php-psr && sudo /usr/bin/phpize"$2"
 | 
			
		||||
  ./configure --with-php-config=/usr/bin/php-config"$2"
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user