Continuous Integration, Deployment, and Reviews for PHP¶
Scrutinizer supports all dependency managers that help PHP developers use during development. For static analysis, Scrutinizer has developed the most advanced static analysis engine that is available for PHP code going beyond simple style checks like whether you are using certain language features in your code. We track how data flows through your application to detect security issues, bugs, unused code, and a lot more.
Generally, we infer most of the configuration based on your project if you follow common best practices. Where this fails,
you can also adjust Scrutinizer's behavior to your needs through configuration. We recommend that you place test related
commands in a .scrutinizer.yml
file while keeping environment variables that contain sensitive data and analysis
related configuration in your repository configuration on the website, or in also in your organization configuration
(see our configuration best practices).
PHP Version¶
Scrutinizer supports any released PHP versions. We try to infer your preferred PHP version and will fall back to a moving default if we are not sure. If you would like to define a specific PHP version, you can set it in your configuration:
build:
nodes:
my-tests:
environment:
php:
version: 7.2 # or any other released version
If you would like to use custom compile options or a specific set of PHP extensions that should be installed. You can configure these compile options in your configuration, and we will compile a custom PHP version and cache it for subsequent builds:
build:
nodes:
my-tests:
environment:
php:
version: 7.2.13
compile_options: '--enable-sigchild --without-pear'
# see https://pecl.php.net/
pecl_extensions:
- redis
- memcached
You can check our default options by starting an inspection in
SSH debug mode, and running
php -i | grep -i configure
in the build container.
INI Settings¶
We use the default development php.ini with some tweaks. Should you like to modify ini settings, you can specify these in your configuration file, and we will automatically populate your ini files with these:
build:
environment:
php:
version: '7.0'
ini:
'date.timezone': 'US/Pacific'
Dependencies¶
Typically, you will want to install your dependencies through composer
. If you have placed a composer.json
file
in your project, we will automatically run the necessary commands for you. We will also infer possible PHP extensions
that you might need and install them for you.
Should you want to install a PHP extension yourself, we provide pecl
in the build environment, and you can simply
run:
build:
nodes:
my-tests:
dependencies:
before:
- pecl install ssh-beta
Databases¶
We provide several databases and queues including MySQL, PostgreSQL, and RabbitMQ pre-installed, if you like you can
also install custom software using sudo apt-get
in your build environment.
Webserver¶
If you would like to run integration tests which access your website through a webserver, we provide easy configuration of Apache2 out-of-the-box:
build:
nodes:
functional-tests:
environment:
hosts:
'local.dev': '127.0.0.1'
apache2:
modules: ['rewrite']
sites:
symfony_app:
web_root: 'web/'
host: 'local.dev'
Testing¶
If you are making use of PHPUnit, phpspec, code ception, or behat, we will automatically infer the test commands for you. You can override the inferred commands in your configuration:
build:
nodes:
my-tests:
tests:
override:
- ./run-tests.sh
Code Coverage¶
By default, we will automatically generate code coverage for your tests. If you change the test commands, you can also generate code-coverage manually. For example, if you are using PHPUnit, your configuration could look like this:
build:
nodes:
my-tests-with-coverage:
tests:
override:
- command: phpunit --coverage-clover=my-coverage-file
coverage:
file: my-coverage-file
format: php-clover
Scrutinizer will automatically process your coverage data and also merge it in case you run your tests in parallel, and also provide graphs that plot its evolution over time.
Deployment¶
Scrutinizer provides first-class support for deployment. Once all your tests have passed, it will automatically trigger deployment of your code. You can define deploy commands in your configuration:
build:
nodes:
deploy:
requires:
- branch: master # you can use either the full branch name,
- branch: /feature_.*/ # or a regular expression
- node: my-tests # only runs if my-tests node succeeded
commands:
- cd deploy && cap deploy
Automated Reviews¶
Learn more about automated reviews for PHP.